[Opencv.js] Compile from source using Emscripten doesn't include VideoCapture()

I am trying to build opencv.js from the source. To do this, I have followed this tutorial. When I clear the functions that I don’t need in opencv_js.config.py, set the cmake options in build_js.py and build with python ./platforms/js/build_js.py build_wasm --build_wasm --emscripten_dir /YOUR_PATH/emsdk/upstream/emscripten, I get a ~3.8Mb file. When I try to run my web app with these files, I get the following error:

Uncaught TypeError: cv.VideoCapture is not a constructor at HTMLVideoElement.<anonymous>

Has anyone built successfully from source including videoio package?

no, there is no VideoCapture class in opencv.js (and no videoio module)

(you’re supposed to use your browser’s builtin html5/js functionality for this,
have a look at examples)

how does that look like ? did you try to literally copypaste python code ?
how comes, there is a VideoCapture in your js code ?

According to the examples, the cv.VideoCapture() is used like this:

let cap = new cv.VideoCapture(video);

And this is the way that I was using it. I took the opencv.js file from this repo which is 13Mb, and I wanted to recompile it from the source using the functions that I need only.

did you try to literally copypaste python code ?

No, everything is vanilla JS.

Thanks for your answer!!

1 Like

apologies for being wrong (did not scroll far enough, i guess)

so again, ther is no videoio module, the cv.VideoCapture is emulated in js here:

and sorry, no idea, why it did not make it into your wasm

1 Like