I want to build my own copy of opencv.js to be able to include image processing function that are not available in the readily available opencv.js.
I followed the build instructions for the 4.7 version using the Docker and emscripten v2.0.10.
The build is successful and generates a seemingly valid custom_opencv.js file.
However, when I try to use this custom version of openCv in one of the documented exemples it does not work properly.
// From the doc
Module = {
onRuntimeInitialized() {
console.log("This is properly called after init");
console.log(cv.getBuildInformation()); // This does not log anything
}
}
cv = require('./opencv.js')
When trying to access an openCv method such as cv.matFromImageData(imageSrc.bitmap);, I get a runtime error TypeError: cv.matFromImageData is not a function.
For comparison, the available opencv.js works perfectly fine.
Any opinion or idea on how to debug this would be appreciated.
I have got the same problem when building opencv.js from source with versions 3.4 and 4.x. on Windows 10 WSL with Emscripten 3.1.44.
I was using this command to build emmake python3 ./opencv/platforms/js/build_js.py build_js --build_test. It have worked, however some of the test were failing.
1. okay@ 1 ms
2. okay@ 1 ms
3. okay@ 1 ms
4. okay@ 1 ms
5. okay@ 1 ms
6. okay@ 1 ms
7. okay@ 1 ms
8. okay@ 1 ms
9. okay@ 1 ms
10. okay@ 1 ms
11. okay@ 1 ms
12. okay@ 1 ms
13. Died on test #13 at http://localhost:8888/test_mat.js:78:7: cv._malloc is not a function@ 2 ms
Source:
TypeError: cv._malloc is not a function
at Object.<anonymous> (http://localhost:8888/test_mat.js:119:23)
When I was following this tutorial. I got an error cv.matFromImageData. I figured out that it was because cv was a promise and after I change to use then it fixed some problems