-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
Building OpenCV.js with projectPoints + solvePnP #15299
Description
Porting to JavaScript: "Cannot register public name 'projectPoints' twice"
I did the following:
-
git clone https://github.com/opencv/opencv.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_calib3dset 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
jsinside 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
solvePnPand '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"
name: "BindingError"
stack: "BindingError: Cannot register public name 'projectPoints' twice↵ at BindingError. (http://localhost/opencv_js/docs/bin/opencv.js:24:9692639)↵ at new BindingError (eval at createNamedFunction (http://localhost/opencv_js/docs/bin/opencv.js:24:9692348), :4:34)↵ at throwBindingError (http://localhost/opencv_js/docs/bin/opencv.js:24:9697766)↵ at exposePublicSymbol (http://localhost/opencv_js/docs/bin/opencv.js:24:9703298)↵ at __embind_register_function (http://localhost/opencv_js/docs/bin/opencv.js:24:9727605)↵ at wasm-function[802]:8129↵ at wasm-function[75]:373↵ at Module.globalCtors (http://localhost/opencv_js/docs/bin/opencv.js:24:9762125)↵ at func (http://localhost/opencv_js/docs/bin/opencv.js:24:9597365)↵ at callRuntimeCallbacks (http://localhost/opencv_js/docs/bin/opencv.js:24:13606)"
proto: Error
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.