4.10.0-release.6 • Published 12 months ago

@dusion/opencv-js v4.10.0-release.6

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
12 months ago

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-js

Setup 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:

  1. Install Emscripten and Python
  2. Clone OpenCV repository
  3. Run build command:
emcmake python ./platforms/js/build_js.py build --disable_single_file

The 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