I did the following:
git clone https://github.com/opencv/opencv.git
git clone https://github.com/opencv/opencv_contrib.git
I added the following in def get_build_flags(self) of opencv/platforms/js/build_js.py: flags += "-s USE_PTHREADS=0 "
I enabled the build flag in def get_cmake_cmd(self): of opencv/platforms/js/build_js.py:
-DBUILD_opencv_calib3d
set toON
I added the following def get_cmake_cmd(self): of opencv/platforms/js/build_js.py:
-DOPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules
I appended
js
inside ocv_define_module at the end of WRAP list of opencv/modules/calib3d/CMakeLists.txt. In opencv/modules/features2d/CMakeLists.txt and opencv_contrib/modules/aruco/CMakeLists.txt also I added "js" parameter in ocv_define_module.I added
solvePnP
and 'projectPoints' in the calib3d module in the opencv/modules/js/src/embindgen.py
calib3d = {'': ['findHomography','calibrateCameraExtended', 'drawFrameAxes', 'getDefaultNewCameraMatrix', 'initUndistortRectifyMap', 'solvePnP','projectPoints']}
- I added the calib3d module to the makeWhiteList in the opencv/modules/js/src/embindgen.py
white_list = makeWhiteList([core, imgproc, objdetect, video, dnn, features2d, photo, aruco, calib3d])
I added "using namespace aruco;" in the opencv/modules/js/src/core_bindings.cpp
I built OpenCV.js using the following command: sudo python ./platforms/js/build_js.py build_js --emscripten_dir=${EMSCRIPTEN} --clean_build_dir --build_test
Before adding these wrappers, it compiled perfectly without errors. Now in my tests.html I have the following message: Downloading... tests.html:61 Running... tests.html:61 Exception thrown, see JavaScript console opencv.js:24 Uncaught BindingError message: "Cannot register public name 'projectPoints' twice"
So seems like the overload functions are preventing me from porting them to JavaScript.
Any suggestions please of how I can fix it?
Thanks in advance for your help.