updated instructions for building with OpenCV + barcode extension through Emscripten

This commit is contained in:
frank 2022-09-26 20:57:51 -04:00
parent 346a059ee2
commit 1ff7f802cb
1 changed files with 14 additions and 5 deletions

View File

@ -80,7 +80,7 @@ Other libraries
These are other libraries that have been used in projects that use this framework but aren't required by the framework
### opencv
### OpenCV
#### Linux
@ -90,12 +90,15 @@ Download from https://opencv.org/releases/ and create a build directory, then co
$ cmake -DCMAKE_INSTALL_PREFIX=$HOME/local/opencv ..
$ make && make install
The libraries can then be linked by adding the following to the linker flags:
The `core`, `imgproc`, `videoio`, and `highgui` modules can then be linked to by adding the following to the linker flags:
-L$(HOME)/local/opencv/lib -Wl,-rpath,$(HOME)/local/opencv/lib -lopencv_videoio -lopencv_core -lopencv_highgui \
-lopencv_imgproc
The specific modules needed at the end of that list may vary depending on the project. There are detailed instructions for building OpenCV on Linux available at https://docs.opencv.org/4.6.0/d7/d9f/tutorial_linux_install.html
The specific modules needed may vary depending on the project. There are detailed instructions for building OpenCV on Linux available at [https://docs.opencv.org/4.6.0/d7/d9f/tutorial_linux_install.html]. There are also contributed modules available, which can be downloaded separately and compiled with the core modules. For example, this command builds all the modules in `../../opencv_contrib-4.x/modules`, except `python3`, along with the core modules.
$ cmake -D CMAKE_INSTALL_PREFIX=$HOME/local/opencv -D OPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-4.x/modules" -D \
BUILD_opencv_python3=OFF ..
#### Emscripten
@ -104,9 +107,15 @@ To build the WASM libraries necessary to include OpenCV in an Emscripten build o
$ source [EMSDK_PATH]/emsdk_env.sh
$ python3 [OPENCV_PATH]/platforms/js/build_js.py --emscripten_dir [EMSCRIPTEN_PATH] build_wasm --build_wasm
There is a detailed explanation of this process at https://docs.opencv.org/4.6.0/d4/da1/tutorial_js_setup.html And useful information for getting around the absence of `cv::VideoCapture` at https://docs.opencv.org/4.6.0/dd/d00/tutorial_js_video_display.html Check out a minimal example of using OpenCV with C++ and Emscripten at https://github.com/mpizenberg/emscripten-opencv
There is a detailed explanation of this process at [https://docs.opencv.org/4.6.0/d4/da1/tutorial_js_setup.html]. And useful information for getting around the absence of `cv::VideoCapture` at [https://docs.opencv.org/4.6.0/dd/d00/tutorial_js_video_display.html]. Check out a minimal example of using OpenCV with C++ and Emscripten at [https://github.com/mpizenberg/emscripten-opencv]. There is also information on how to build the contributed modules as WASM libraries in the first link.
### zbar
At the time of writing this, the contributed module for barcode scanning needs `-DBUILD_PROTOBUF=ON` added to the `build_js.py` script and needs `js` added to its list of wrapper languages in its `CMakeLists.txt` file to compile successfully.
To link to the WASM libraries, add the `*.a` files from the build directory to Emscripten's linker flags. Add both `lib/*.a` and `3rdparty/lib/*.a`. For GNU Make, this might look like the following.
$(wildcard $(addprefix $(WASM_BUILD_DIR)/lib/,*.a)) $(wildcard $(addprefix $(WASM_BUILD_DIR)/3rdparty/lib/,*.a))
### ZBar
#### Linux