0

I want to use opencv in node. Found @techstark/opencv-js and looks promising, but I cannot run even a simple example. I've installed the examples from https://github.com/TechStark/opencv-js-examples. I'm using Node v22.18.0

My simple program:

    const { getOpenCv } = require("./opencv.js");
    
    async function main() {
      const { cv } = await getOpenCv();
      console.log("OpenCV.js is ready!");
      console.log(cv.getBuildInformation());
      const inputImage = cv.imread("Lenna.png");
      console.log("Done");
    }
    
    main();

Run with:

> npm run commonjs

Throws this error:

(build info, as expected) (a very long block of obfuscated code)

abort(ReferenceError: document is not defined). Build with -s ASSERTIONS=1 for more info. (Use node --trace-uncaught ... to show where the exception was thrown)

Node.js v22.18.0

I tried an earlier version with similar outcome. I don't know where the problem is: in techstark's package, the opencv js port (the author says it's downloaded directly from its source), an incompatibility with node.js, my own setup, or what.

2
  • @techstark provides the package. please direct your support request to @techstark. Commented Nov 12 at 11:39
  • @ChristophRackwitz thanks, I've filed a bug report. But I'm not sure the package is actually the culprit, might be something else. Commented Nov 12 at 12:19

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.