webarkit / opencv-em

A simple utility script to build OpenCV static libs with Emscripten
GNU General Public License v3.0
19 stars 3 forks source link
emscripten hacktoberfest opencv opencvjs wasm

opencv-em

A simple script utility to build with Emscripten OpenCV static libs. You can build the libs by yourself or grab them from a Release

Building OpenCV with Emscripten

If you want to build the libs, you need Emscripten. Install the emsdk as suggested in the Emscripten website. Then you can clone this repository:

git clone https://github.com/webarkit/opencv-em.git

you need also to init the OpenCV submodule:

git submodule update --init

Then you can run the build script (./build.sh) with either linux or emscripten configuration. Note: If you'd like the include file structure to mimic a default OpenCV installation inside the generated archive for emscripten, you'll need to do both and start with a linux build:

./build.sh linux

Then, move on to the emscripten build:

./build.sh emscripten

Pre-built binaries

You don't need to build the libs you can grab from Releases

Use of pre-built binaries

You can use FetchContent in a cmake project (CMakeLists.txt):

include(FetchContent)

FetchContent_Declare(
  build_opencv
 URL https://github.com/webarkit/opencv-em/releases/download/0.1.4/opencv-4.7.0.zip
)

FetchContent_MakeAvailable(build_opencv)

or you can use curl or bootstrapping to download the package and make it available to your project.