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

asked 2019-08-14 05:52:23 -0600

kavikode gravatar image

updated 2019-08-15 18:59:16 -0600

I did the following:

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

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

  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:



Thanks in advance for your help.

edit retag flag offensive close merge delete