Merge pull request #23725 from asmorkalov:as/aruco_js_refresh

Refreshed JavaScript bindings for Aruco related algorithms
This commit is contained in:
Alexander Smorkalov 2023-06-10 09:21:24 +03:00 committed by GitHub
commit 6ca697bc12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 74 additions and 9 deletions

View File

@ -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

View File

@ -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

View File

@ -200,3 +200,59 @@ QUnit.test('QR code detect and decode', function (assert) {
}
});
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();
}
});

View File

@ -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 = {