How to install Opencv-JS
First of all we need the OpenCV sources. To build JS file you should install emscripten. Installation is really easy just check this link. Emscripten is a toolchain for compiling to asm.js and WebAssembly, built using LLVM, that lets you run C and C++ on the web at near-native speed without plugins. This is a really useful SDK and I would like to share more about it in later posts.
The next Step is like following:
opencv.js, execute python script
<opencv_src_dir>/platforms/js/build_js.py <build_dir>. For example, to build in
>>python ./platforms/js/build_js.py build_js
Note: It requires
cmake installed in your development environment.
2.The build script builds asm.js version by default. To build WebAssembly version, append
--build_wasm switch. For example, to build wasm version in
>> python ./platforms/js/build_js.py build_wasm –build_wasm
[optional] To build documents, append
--build_doc option. For example: >>python ./platforms/js/build_js.py build_js –build_doc
Note: It requires
doxygen installed in your development environment.
[optional] To build tests, append
--build_test option. For example: python ./platforms/js/build_js.py build_js –build_testTo run tests, launch a local web server in <build_dir>/bin folder. For example, node http-server which serves on
localhost:8080. Navigate the web browser to
http://localhost:8080/tests.html, which runs the unit tests automatically. You can also run tests using Node.js. For example: cd binnpm installnode tests.jsNoteIt requires
node installed in your development environment.
Now you can test your code. Take a photo from you and draw a red rectangular boarder around it. It’s really simple and fun. you can download the pre-built library in this link