diff --git a/modules/js/generator/embindgen.py b/modules/js/generator/embindgen.py index f9b8431402..dee778a9de 100644 --- a/modules/js/generator/embindgen.py +++ b/modules/js/generator/embindgen.py @@ -812,6 +812,7 @@ class JSWrapperGenerator(object): for name, class_info in sorted(self.classes.items()): class_bindings = [] if not name in white_list: + #print('Not in whitelist: "{}" from ns={}'.format(name, ns_name)) continue # Generate bindings for methods diff --git a/modules/js/src/core_bindings.cpp b/modules/js/src/core_bindings.cpp index 1f86711c16..ee980aacb2 100644 --- a/modules/js/src/core_bindings.cpp +++ b/modules/js/src/core_bindings.cpp @@ -89,14 +89,12 @@ using namespace cv; using namespace cv::segmentation; // FIXIT +using namespace cv::aruco; + #ifdef HAVE_OPENCV_DNN using namespace cv::dnn; #endif -#ifdef HAVE_OPENCV_ARUCO -using namespace aruco; -#endif - #ifdef HAVE_OPENCV_VIDEO typedef TrackerMIL::Params TrackerMIL_Params; #endif diff --git a/modules/js/test/test_objdetect.js b/modules/js/test/test_objdetect.js index dc863d682f..7c481eb10a 100644 --- a/modules/js/test/test_objdetect.js +++ b/modules/js/test/test_objdetect.js @@ -199,4 +199,60 @@ QUnit.test('QR code detect and decode', function (assert) { mat.delete(); } -}); \ No newline at end of file +}); +QUnit.test('Aruco detector', function (assert) { + { + let dictionary = cv.getPredefinedDictionary(cv.DICT_4X4_50); + let aruco_image = new cv.Mat(); + let detectorParameters = new cv.aruco_DetectorParameters(); + let refineParameters = new cv.aruco_RefineParameters(10, 3, true); + let detector = new cv.aruco_ArucoDetector(dictionary, detectorParameters,refineParameters); + let corners = new cv.MatVector(); + let ids = new cv.Mat(); + + dictionary.generateImageMarker(10, 128, aruco_image); + assert.ok(!aruco_image.empty()); + + detector.detectMarkers(aruco_image, corners, ids); + + dictionary.delete(); + aruco_image.delete(); + detectorParameters.delete(); + refineParameters.delete(); + detector.delete(); + corners.delete(); + ids.delete(); + } +}); +QUnit.test('Charuco detector', function (assert) { + { + let dictionary = new cv.getPredefinedDictionary(cv.DICT_4X4_50); + let boardIds = new cv.Mat(); + let board = new cv.aruco_CharucoBoard(new cv.Size(3, 5), 64, 32, dictionary, boardIds); + let charucoParameters = new cv.aruco_CharucoParameters(); + let detectorParameters = new cv.aruco_DetectorParameters(); + let refineParameters = new cv.aruco_RefineParameters(10, 3, true); + let detector = new cv.aruco_CharucoDetector(board, charucoParameters, detectorParameters, refineParameters); + let board_image = new cv.Mat(); + let corners = new cv.Mat(); + let ids = new cv.Mat(); + + board.generateImage(new cv.Size(300, 500), board_image); + assert.ok(!board_image.empty()); + + detector.detectBoard(board_image, corners, ids); + assert.ok(!corners.empty()); + assert.ok(!ids.empty()); + + dictionary.delete(); + boardIds.delete(); + board.delete(); + board_image.delete(); + charucoParameters.delete(); + detectorParameters.delete(); + refineParameters.delete(); + detector.delete(); + corners.delete(); + ids.delete(); + } +}); diff --git a/platforms/js/opencv_js.config.py b/platforms/js/opencv_js.config.py index fe91e3334e..65a1c95d52 100644 --- a/platforms/js/opencv_js.config.py +++ b/platforms/js/opencv_js.config.py @@ -108,13 +108,23 @@ imgproc = { ], } -objdetect = {'': ['groupRectangles'], +objdetect = {'': ['groupRectangles', 'getPredefinedDictionary', 'extendDictionary', + 'drawDetectedMarkers', 'generateImageMarker', 'drawDetectedCornersCharuco', + 'drawDetectedDiamonds'], 'HOGDescriptor': ['load', 'HOGDescriptor', 'getDefaultPeopleDetector', 'getDaimlerPeopleDetector', 'setSVMDetector', 'detectMultiScale'], 'CascadeClassifier': ['load', 'detectMultiScale2', 'CascadeClassifier', 'detectMultiScale3', 'empty', 'detectMultiScale'], 'QRCodeDetector': ['QRCodeDetector', 'decode', 'decodeCurved', 'detect', 'detectAndDecode', 'detectMulti', 'setEpsX', 'setEpsY'], - 'ArucoDetector': ['getPredefinedDictionary', 'detectMarkers', 'refineDetectedMarkers', 'getDictionary', 'setDictionary', 'getDetectorParameters', 'setDetectorParameters', 'getRefineParameters', 'setRefineParameters'], - 'GridBoard': ['create','generateImage', 'getGridSize', 'getMarkerLength', 'getMarkerSeparation'], - 'CharucoBoard': ['create', 'generateImage', 'getChessboardCorners', 'getNearestMarkerCorners', 'checkCharucoCornersCollinear'] + # aruco namespace + 'aruco_PredefinedDictionaryType': [], + 'aruco_Dictionary': ['Dictionary', 'getDistanceToId', 'generateImageMarker', 'getByteListFromBits', 'getBitsFromByteList'], + 'aruco_Board': ['Board', 'matchImagePoints', 'generateImage'], + 'aruco_GridBoard': ['GridBoard', 'generateImage', 'getGridSize', 'getMarkerLength', 'getMarkerSeparation', 'matchImagePoints'], + 'aruco_CharucoParameters': ['CharucoParameters'], + 'aruco_CharucoBoard': ['CharucoBoard', 'generateImage', 'getChessboardCorners', 'getNearestMarkerCorners', 'checkCharucoCornersCollinear', 'matchImagePoints', 'getLegacyPattern', 'setLegacyPattern'], + 'aruco_DetectorParameters': ['DetectorParameters'], + 'aruco_RefineParameters': ['RefineParameters'], + 'aruco_ArucoDetector': ['ArucoDetector', 'detectMarkers', 'refineDetectedMarkers', 'setDictionary', 'setDetectorParameters', 'setRefineParameters'], + 'aruco_CharucoDetector': ['CharucoDetector', 'setBoard', 'setCharucoParameters', 'setDetectorParameters', 'setRefineParameters', 'detectBoard', 'detectDiamonds'] } video = {