export OPENCV_BUILD_ROOT
to a openCV source workdir.
build openCV and keep sources with:
npm run build-opencv
then duplicate and update your environement in .vscode/c_cpp_properties.json
if needed,
in vscode choose the correct C/C++ configuration at the bootom rigth of your screen.
node-gyp rebuild; ts-node-cwd.CMD .\src\index.ts
npm run test
doc: https://docs.conda.io/projects/conda/en/4.6.0/user-guide/tasks/manage-environments.html
# list availible env:
conda info --envs
# list package in the dedicate env:
conda create --name opencv-sandbox python=3.7
conda list -n opencv-sandbox
conda activate opencv-sandbox
pip install -e .
Headers should be present somewhere in your opencv install like :
cp ${OPENCV_BUILD_ROOT}/latest/build/modules/python_bindings_generator/headers.txt data/headers.txt
cp ${Env:OPENCV_BUILD_ROOT}/latest/build/modules/python_bindings_generator/headers.txt data/headers.txt
To generate only part of the bindings, you can remove line from data/headers.txt
The minimum data/headers.txt
file is
${OPENCV_BUILD_ROOT}/latest/build/modules/core/include/opencv2/core.hpp
${Env:OPENCV_BUILD_ROOT}/latest/build/modules/core/include/opencv2/core.hpp
%OPENCV_BUILD_ROOT%/latest/build/modules/core/include/opencv2/core.hpp
cd ${Env:OPENCV_BUILD_ROOT}/latest/opencv/modules/python/src2
conda activate opencv-sandbox
mkdir dst
python gen2.py dst
Once the headers.txt
is ready you can do
mkdir -p cc-generated
python nodejs_opencv_generator/gen2.py cc-generated data/headers.txt
The code whould be visible in cc-generated
on linux you may face Error: libopencv_imgcodecs.so.407: cannot open shared object file: No such file or directory
You can fix it like
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${OPENCV_BUILD_ROOT}/latest/build/lib/