opencv-wasm
opencv-wasm copied to clipboard
Is web environment supported?
The README says "Precompiled OpenCV to JavaScript + WebAssembly for node.js and deno environment", but is web environment supported?
If not, will opencv-wasm also add support for web soon (and is it hard to do)?
Hello, currently, I designated this repo to make importing OpenCV.js in node.js and deno easy.
For the web browser, you can actually use directly the OpenCV.js that's provided from their website: https://docs.opencv.org/3.4/d0/d84/tutorial_js_usage.html
If you meant making this package (opencv-wasm) compatible with bundler tools (e.g., webpack), I'd need to work on that and make sure that it's integrated smoothly. But I couldn't give you a time estimation on when I'll do that. 🙏
you can actually use directly the OpenCV.js that's provided from their website: https://docs.opencv.org/3.4/d0/d84/tutorial_js_usage.html
I think opencv.js (like https://docs.opencv.org/3.4.0/opencv.js) is asm.js, not WebAssembly?
Aha yeah, just checked the file (https://docs.opencv.org/3.4.0/opencv.js), it doesn't use WebAssembly.
Compiling to the Wasm version wouldn't be complicated though. You can do it yourself by following this tutorial https://docs.opencv.org/4.3.0/d4/da1/tutorial_js_setup.html. The key is using the --build_wasm option.
I'm new to WASM, so sorry for my curiosity:
- What's the difference between the result of this GitHub project, and the result created by https://docs.opencv.org/4.3.0/d4/da1/tutorial_js_setup.html ?
- What's the difference between running WASM in web browser, and in Nodejs?
What's the difference between the result of this GitHub project, and the result created by https://docs.opencv.org/4.3.0/d4/da1/tutorial_js_setup.html ?
The opencv-wasm npm module is the result of the tutorial above + some changes in the flag + some addition in the JS code. Therefore, you can install OpenCV Wasm easily in your Node.js project by npm install opencv-wasm or in deno by importing the deno module.
What's the difference between running WASM in web browser, and in Nodejs?
The produced Wasm from the tutorial above can run in Node.js and web browser. But of course, in Node.js you get file system access.
FYI (semi-related): There is some discussion on the official opencv repo around making a web-friendly npm packaged version in https://github.com/opencv/opencv/issues/15315
Thanks @0xdevalias for informing me! It seems there is a lot of demand for it. I'll certainly work on it when I get time to do it. 😃