opencv-js icon indicating copy to clipboard operation
opencv-js copied to clipboard

Cannot use in node.js

Open fr-an-k opened this issue 1 year ago • 1 comments

The documentation says it can be used in node.j but if I do:

import cv from '@techstark/opencv-js'
console.log(cv.getBuildInformation())

I get TypeError: cv.getBuildInformation is not a function

If I use cv.imread('file.jpg') I get ReferenceError: document is not defined

I tried using node:module createRequire and then require it but that yields the same issue.

I did see it works in CodeSandbox: https://codesandbox.io/p/devbox/angry-dust-0dzjip but I don't manage to do it it in WSL.

fr-an-k avatar Oct 06 '24 09:10 fr-an-k

@fr-an-k check the tests in https://github.com/TechStark/opencv-js/tree/main/test, which run in node.js

ttt43ttt avatar Oct 25 '24 04:10 ttt43ttt

How do I run the tests? They don't run with node and there is no documentation.

fr-an-k avatar Nov 03 '24 00:11 fr-an-k

Yeah I'm also finding it doesn't work at all in node with the same error

Goolyio avatar Mar 28 '25 16:03 Goolyio

I've added node.js example here https://github.com/TechStark/opencv-js-examples/tree/main/opencv-js-node-example

ttt43ttt avatar Apr 04 '25 13:04 ttt43ttt