4.10.0-release.6 • Published 12 months ago
@dusion/opencv-js v4.10.0-release.6
opencv-js
forked from https://github.com/TechStark/opencv-js
OpenCV JavaScript version (NPM package) for node.js or browser, with TypeScript support.
Features
- Independent WASM file for smaller bundle size
- Async
loadOpenCV()method to control WASM loading - Specify custom WASM file location
- Full TypeScript support
Installation
npm install @dusion/opencv-js
# or
yarn add @dusion/opencv-jsSetup WASM File
Copy node_modules/@dusion/opencv-js/lib/opencv_js.wasm to your project's public directory.
Usage
import cv from "@dusion/opencv-js"
// Load from URL
await cv.loadOpenCV('/path/to/opencv_js.wasm')
// Or load from ArrayBuffer
const response = await fetch('/path/to/opencv_js.wasm');
const wasmBinary = await response.arrayBuffer();
await cv.loadOpenCV(wasmBinary)
// Then use OpenCV APIs
const mat = new cv.Mat()Build WASM
If you want to build the WASM file yourself:
- Install Emscripten and Python
- Clone OpenCV repository
- Run build command:
emcmake python ./platforms/js/build_js.py build --disable_single_fileThe WASM file will be generated in build_js/bin/opencv_js.wasm
API Reference
For available OpenCV.js APIs, please refer to:
4.10.0-release.6
12 months ago
4.10.0-release.5
12 months ago
4.10.0-release.4
12 months ago
4.10.0-release.3
12 months ago
4.10.0-release.2
1 year ago