Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Porting to JavaScript: "Cannot register public name 'projectPoints' twice"

I did the following:

  1. git clone https://github.com/opencv/opencv.git

  2. git clone https://github.com/opencv/opencv_contrib.git

  3. I added the following in def get_build_flags(self) of opencv/platforms/js/build_js.py: flags += "-s USE_PTHREADS=0 "

  4. I enabled the build flag in def get_cmake_cmd(self): of opencv/platforms/js/build_js.py:-DBUILD_opencv_calib3d set to ON

  5. I added the following def get_cmake_cmd(self): of opencv/platforms/js/build_js.py:-DOPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules

  6. 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.

  7. I added solvePnPand 'projectPoints' in the calib3d module in the opencv/modules/js/src/embindgen.py

calib3d = {'': ['findHomography','calibrateCameraExtended', 'drawFrameAxes', 'getDefaultNewCameraMatrix', 'initUndistortRectifyMap', 'solvePnP','projectPoints']}

  1. 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])

  1. I added "using namespace aruco;" in the opencv/modules/js/src/core_bindings.cpp

  2. 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.

Porting to JavaScript: "Cannot register public name 'projectPoints' twice"

I did the following:

  1. git clone https://github.com/opencv/opencv.git

  2. git clone https://github.com/opencv/opencv_contrib.git

  3. I added the following in def get_build_flags(self) of opencv/platforms/js/build_js.py: flags += "-s USE_PTHREADS=0 "

  4. I enabled the build flag in def get_cmake_cmd(self): of opencv/platforms/js/build_js.py:-DBUILD_opencv_calib3d set to ON

  5. I added the following def get_cmake_cmd(self): of opencv/platforms/js/build_js.py:-DOPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules

  6. 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.

  7. I added solvePnPand 'projectPoints' in the calib3d module in the opencv/modules/js/src/embindgen.py

calib3d = {'': ['findHomography','calibrateCameraExtended', 'drawFrameAxes', 'getDefaultNewCameraMatrix', 'initUndistortRectifyMap', 'solvePnP','projectPoints']}

  1. 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])

  1. I added "using namespace aruco;" in the opencv/modules/js/src/core_bindings.cpp

  2. 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?

Here is the Pull Request:

https://github.com/opencv/opencv/pull/15311

https://github.com/opencv/opencv_contrib/pull/2228

Thanks in advance for your help.