Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
O

opencv-js

> 包管理
Open source

OpenCV JavaScript version for node.js or browser

760 stars0 likes0 views
WebsiteGitHub

About

OpenCV JavaScript version for node.js or browser

opencv-js

OpenCV JavaScript version (NPM package) for node.js or browser. Get started guide OpenCV.js Tutorials.

The file opencv.js was downloaded from https://docs.opencv.org/5.0.0/opencv.js

TypeScript is supported (thanks to mirada).

Basic Usage

javascript
import cvModule from "@techstark/opencv-js";

async function getOpenCv() {
  let cv;
  if (cvModule instanceof Promise) {
    cv = await cvModule;
  } else {
    if (cvModule.Mat) {
      cv = cvModule;
    } else {
      await new Promise((resolve) => {
        cvModule.onRuntimeInitialized = () => resolve();
      });
      cv = cvModule;
    }
  }
  return { cv };
}

async function main() {
  const { cv } = await getOpenCv();
  console.log("OpenCV.js is ready!");
  // You can now use OpenCV functions here
  console.log(cv.getBuildInformation());
}

main();

Code Examples

  • See code examples (React, Angular, Node.js) in opencv-js-examples

Live Demo

Using in react.js project

  • See live demo and code here

  • Get the test image from here Lenna.png

Using in Angular project

  • See code here

Real-time face detection

  • See live demo and code here

How to Use

  • npm install @techstark/opencv-js
  • or yarn add @techstark/opencv-js
  • import cv from "@techstark/opencv-js"
    • for TypeScript, set "esModuleInterop": true in tsconfig.json
  • or import * as cv from "@techstark/opencv-js"

Webpack Configuration (for browser usage)

If you use this package for browsers, you need to set some polyfills. In the file "webpack.config.js", set

javascript
module.exports = {
  resolve: {
    modules: [...],
    fallback: {
      fs: false,
      path: false,
      crypto: false
    }
  }
};

What methods and properties are available

The TypeScript type declarations may not be up to date with the latest OpenCV.js. Refer to cvKeys.json to check the available methods and properties at runtime.

Star History

Star History

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

TypeScriptjsnpm-packageopencv

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category包管理
PricingOpen source

> Related tools

N
npm
Node.js 默认包管理器
P
pnpm
高效节省磁盘的 Node 包管理器
I
is-gif
Check if a Buffer/Uint8Array is a GIF image