From 5bd62f72bed65f8065693308076200e8c61cd21b Mon Sep 17 00:00:00 2001 From: AleksandrPanov Date: Wed, 4 May 2022 19:56:30 +0300 Subject: [PATCH] update tests and samples to class API --- modules/aruco/include/opencv2/aruco.hpp | 1 + .../aruco/include/opencv2/aruco_detector.hpp | 46 ++++++++- modules/aruco/perf/perf_aruco.cpp | 9 +- modules/aruco/perf/perf_precomp.hpp | 2 +- modules/aruco/samples/aruco_dict_utils.cpp | 2 +- .../aruco/samples/aruco_samples_utility.hpp | 2 +- modules/aruco/samples/calibrate_camera.cpp | 9 +- modules/aruco/samples/create_board.cpp | 2 +- modules/aruco/samples/create_marker.cpp | 2 +- modules/aruco/samples/detect_board.cpp | 11 ++- modules/aruco/samples/detect_markers.cpp | 7 +- .../src/apriltag/apriltag_quad_thresh.hpp | 2 +- modules/aruco/src/aruco_detector.cpp | 52 +--------- modules/aruco/test/test_arucodetection.cpp | 96 +++++++++---------- modules/aruco/test/test_boarddetection.cpp | 30 +++--- modules/aruco/test/test_charucodetection.cpp | 63 ++++++------ modules/aruco/test/test_precomp.hpp | 1 - modules/ovis/samples/aruco_ar_demo.cpp | 2 +- 18 files changed, 172 insertions(+), 167 deletions(-) diff --git a/modules/aruco/include/opencv2/aruco.hpp b/modules/aruco/include/opencv2/aruco.hpp index 2f12678ff3c..6143b257568 100644 --- a/modules/aruco/include/opencv2/aruco.hpp +++ b/modules/aruco/include/opencv2/aruco.hpp @@ -40,6 +40,7 @@ the use of this software, even if advised of the possibility of such damage. #define __OPENCV_ARUCO_HPP__ #include "opencv2/aruco_detector.hpp" +#include "opencv2/aruco/aruco_calib_pose.hpp" /** * @defgroup aruco ArUco Marker Detection diff --git a/modules/aruco/include/opencv2/aruco_detector.hpp b/modules/aruco/include/opencv2/aruco_detector.hpp index f816033e20d..724b4923936 100644 --- a/modules/aruco/include/opencv2/aruco_detector.hpp +++ b/modules/aruco/include/opencv2/aruco_detector.hpp @@ -100,8 +100,48 @@ enum CornerRefineMethod{ * The parameter tau_i has a direct influence on the processing speed. */ struct CV_EXPORTS_W DetectorParameters { - DetectorParameters(); - CV_WRAP static Ptr create(); + DetectorParameters(): + adaptiveThreshWinSizeMin(3), + adaptiveThreshWinSizeMax(23), + adaptiveThreshWinSizeStep(10), + adaptiveThreshConstant(7), + minMarkerPerimeterRate(0.03), + maxMarkerPerimeterRate(4.), + polygonalApproxAccuracyRate(0.03), + minCornerDistanceRate(0.05), + minDistanceToBorder(3), + minMarkerDistanceRate(0.05), + cornerRefinementMethod(CORNER_REFINE_NONE), + cornerRefinementWinSize(5), + cornerRefinementMaxIterations(30), + cornerRefinementMinAccuracy(0.1), + markerBorderBits(1), + perspectiveRemovePixelPerCell(4), + perspectiveRemoveIgnoredMarginPerCell(0.13), + maxErroneousBitsInBorderRate(0.35), + minOtsuStdDev(5.0), + errorCorrectionRate(0.6), + aprilTagQuadDecimate(0.0), + aprilTagQuadSigma(0.0), + aprilTagMinClusterPixels(5), + aprilTagMaxNmaxima(10), + aprilTagCriticalRad( (float)(10* CV_PI /180) ), + aprilTagMaxLineFitMse(10.0), + aprilTagMinWhiteBlackDiff(5), + aprilTagDeglitch(0), + detectInvertedMarker(false), + useAruco3Detection(false), + minSideLengthCanonicalImg(32), + minMarkerLengthRatioOriginalImg(0.0) {}; + +/** + * @brief Create a new set of DetectorParameters with default values. + */ + CV_WRAP static Ptr create() { + Ptr params = makePtr(); + return params; +} + CV_WRAP bool readDetectorParameters(const FileNode& fn); CV_PROP_RW int adaptiveThreshWinSizeMin; @@ -145,6 +185,7 @@ struct CV_EXPORTS_W DetectorParameters { CV_PROP_RW bool useAruco3Detection; CV_PROP_RW int minSideLengthCanonicalImg; CV_PROP_RW float minMarkerLengthRatioOriginalImg; + }; struct CV_EXPORTS_W RefineParameters { @@ -285,7 +326,6 @@ CV_EXPORTS_W void drawDetectedMarkers(InputOutputArray image, InputArrayOfArrays */ CV_EXPORTS_W void drawMarker(const Ptr &dictionary, int id, int sidePixels, OutputArray img, int borderBits = 1); -//}; //! @} diff --git a/modules/aruco/perf/perf_aruco.cpp b/modules/aruco/perf/perf_aruco.cpp index 6ab830fa280..6cde729ff2e 100644 --- a/modules/aruco/perf/perf_aruco.cpp +++ b/modules/aruco/perf/perf_aruco.cpp @@ -190,6 +190,7 @@ PERF_TEST_P(EstimateAruco, ArucoFirst, ESTIMATE_PARAMS) detectorParams->minSideLengthCanonicalImg = 32; detectorParams->minMarkerLengthRatioOriginalImg = 0.04f / numMarkersInRow; } + aruco::ArucoDetector detector(dictionary, detectorParams); MarkerPainter painter(markerSize); auto image_map = painter.getProjectMarkersTile(numMarkersInRow, detectorParams, dictionary); @@ -198,7 +199,7 @@ PERF_TEST_P(EstimateAruco, ArucoFirst, ESTIMATE_PARAMS) vector ids; TEST_CYCLE() { - aruco::detectMarkers(image_map.first, dictionary, corners, ids, detectorParams); + detector.detectMarkers(image_map.first, corners, ids); } ASSERT_EQ(numMarkersInRow*numMarkersInRow, static_cast(ids.size())); double maxDistance = getMaxDistance(image_map.second, ids, corners); @@ -221,6 +222,7 @@ PERF_TEST_P(EstimateAruco, ArucoSecond, ESTIMATE_PARAMS) detectorParams->minSideLengthCanonicalImg = 64; detectorParams->minMarkerLengthRatioOriginalImg = 0.f; } + aruco::ArucoDetector detector(dictionary, detectorParams); const int markerSize = 200; const int numMarkersInRow = 11; MarkerPainter painter(markerSize); @@ -231,7 +233,7 @@ PERF_TEST_P(EstimateAruco, ArucoSecond, ESTIMATE_PARAMS) vector ids; TEST_CYCLE() { - aruco::detectMarkers(image_map.first, dictionary, corners, ids, detectorParams); + detector.detectMarkers(image_map.first, corners, ids); } ASSERT_EQ(numMarkersInRow*numMarkersInRow, static_cast(ids.size())); double maxDistance = getMaxDistance(image_map.second, ids, corners); @@ -276,6 +278,7 @@ PERF_TEST_P(EstimateLargeAruco, ArucoFHD, ESTIMATE_FHD_PARAMS) detectorParams->minSideLengthCanonicalImg = get<0>(testParams).minSideLengthCanonicalImg; detectorParams->minMarkerLengthRatioOriginalImg = get<0>(testParams).minMarkerLengthRatioOriginalImg; } + aruco::ArucoDetector detector(dictionary, detectorParams); const int markerSize = get<1>(testParams).first; // 1440 or 480 or 144 const int numMarkersInRow = get<1>(testParams).second; // 1 or 3 or 144 MarkerPainter painter(markerSize); // num pixels is 1440x1440 as in FHD 1920x1080 @@ -286,7 +289,7 @@ PERF_TEST_P(EstimateLargeAruco, ArucoFHD, ESTIMATE_FHD_PARAMS) vector ids; TEST_CYCLE() { - aruco::detectMarkers(image_map.first, dictionary, corners, ids, detectorParams); + detector.detectMarkers(image_map.first, corners, ids); } ASSERT_EQ(numMarkersInRow*numMarkersInRow, static_cast(ids.size())); double maxDistance = getMaxDistance(image_map.second, ids, corners); diff --git a/modules/aruco/perf/perf_precomp.hpp b/modules/aruco/perf/perf_precomp.hpp index e4df3216e0c..a72903624c8 100644 --- a/modules/aruco/perf/perf_precomp.hpp +++ b/modules/aruco/perf/perf_precomp.hpp @@ -5,7 +5,7 @@ #define __OPENCV_PERF_PRECOMP_HPP__ #include "opencv2/ts.hpp" -#include "opencv2/aruco.hpp" +#include "opencv2/aruco_detector.hpp" #include "opencv2/calib3d.hpp" #endif diff --git a/modules/aruco/samples/aruco_dict_utils.cpp b/modules/aruco/samples/aruco_dict_utils.cpp index 465513b3410..ab32f4f58a9 100644 --- a/modules/aruco/samples/aruco_dict_utils.cpp +++ b/modules/aruco/samples/aruco_dict_utils.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include using namespace cv; diff --git a/modules/aruco/samples/aruco_samples_utility.hpp b/modules/aruco/samples/aruco_samples_utility.hpp index c1cfe626cb7..ebdbcc1d7ec 100644 --- a/modules/aruco/samples/aruco_samples_utility.hpp +++ b/modules/aruco/samples/aruco_samples_utility.hpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include diff --git a/modules/aruco/samples/calibrate_camera.cpp b/modules/aruco/samples/calibrate_camera.cpp index a52bab5b161..bf056b15270 100644 --- a/modules/aruco/samples/calibrate_camera.cpp +++ b/modules/aruco/samples/calibrate_camera.cpp @@ -39,7 +39,8 @@ the use of this software, even if advised of the possibility of such damage. #include #include -#include +#include +#include #include #include #include @@ -162,6 +163,8 @@ int main(int argc, char *argv[]) { vector< vector< int > > allIds; Size imgSize; + aruco::ArucoDetector detector(dictionary, detectorParams); + while(inputVideo.grab()) { Mat image, imageCopy; inputVideo.retrieve(image); @@ -170,10 +173,10 @@ int main(int argc, char *argv[]) { vector< vector< Point2f > > corners, rejected; // detect markers - aruco::detectMarkers(image, dictionary, corners, ids, detectorParams, rejected); + detector.detectMarkers(image, corners, ids, rejected); // refind strategy to detect more markers - if(refindStrategy) aruco::refineDetectedMarkers(image, board, corners, ids, rejected); + if(refindStrategy) detector.refineDetectedMarkers(image, board, corners, ids, rejected); // draw results image.copyTo(imageCopy); diff --git a/modules/aruco/samples/create_board.cpp b/modules/aruco/samples/create_board.cpp index d2482bce853..242688e5cb7 100644 --- a/modules/aruco/samples/create_board.cpp +++ b/modules/aruco/samples/create_board.cpp @@ -38,7 +38,7 @@ the use of this software, even if advised of the possibility of such damage. #include -#include +#include #include #include "aruco_samples_utility.hpp" diff --git a/modules/aruco/samples/create_marker.cpp b/modules/aruco/samples/create_marker.cpp index fe31ec2972f..73ce21880f6 100644 --- a/modules/aruco/samples/create_marker.cpp +++ b/modules/aruco/samples/create_marker.cpp @@ -38,7 +38,7 @@ the use of this software, even if advised of the possibility of such damage. #include -#include +#include #include #include "aruco_samples_utility.hpp" diff --git a/modules/aruco/samples/detect_board.cpp b/modules/aruco/samples/detect_board.cpp index 883be8dd2e3..7f9c3d1ebc7 100644 --- a/modules/aruco/samples/detect_board.cpp +++ b/modules/aruco/samples/detect_board.cpp @@ -38,7 +38,8 @@ the use of this software, even if advised of the possibility of such damage. #include -#include +#include +#include #include #include #include "aruco_samples_utility.hpp" @@ -135,7 +136,7 @@ int main(int argc, char *argv[]) { cerr << "Dictionary not specified" << endl; return 0; } - + aruco::ArucoDetector detector(dictionary, detectorParams); VideoCapture inputVideo; int waitTime; if(!video.empty()) { @@ -168,12 +169,12 @@ int main(int argc, char *argv[]) { Vec3d rvec, tvec; // detect markers - aruco::detectMarkers(image, dictionary, corners, ids, detectorParams, rejected); + detector.detectMarkers(image, corners, ids, rejected); // refind strategy to detect more markers if(refindStrategy) - aruco::refineDetectedMarkers(image, board, corners, ids, rejected, camMatrix, - distCoeffs); + detector.refineDetectedMarkers(image, board, corners, ids, rejected, camMatrix, + distCoeffs); // estimate board pose int markersOfBoardDetected = 0; diff --git a/modules/aruco/samples/detect_markers.cpp b/modules/aruco/samples/detect_markers.cpp index f7d17b9f8a8..de38c2a1b2c 100644 --- a/modules/aruco/samples/detect_markers.cpp +++ b/modules/aruco/samples/detect_markers.cpp @@ -38,7 +38,8 @@ the use of this software, even if advised of the possibility of such damage. #include -#include +#include +#include #include #include "aruco_samples_utility.hpp" @@ -134,7 +135,7 @@ int main(int argc, char *argv[]) { return 0; } } - + aruco::ArucoDetector detector(dictionary, detectorParams); VideoCapture inputVideo; int waitTime; if(!video.empty()) { @@ -159,7 +160,7 @@ int main(int argc, char *argv[]) { vector< Vec3d > rvecs, tvecs; // detect markers and estimate pose - aruco::detectMarkers(image, dictionary, corners, ids, detectorParams, rejected); + detector.detectMarkers(image, corners, ids, rejected); if(estimatePose && ids.size() > 0) aruco::estimatePoseSingleMarkers(corners, markerLength, camMatrix, distCoeffs, rvecs, tvecs); diff --git a/modules/aruco/src/apriltag/apriltag_quad_thresh.hpp b/modules/aruco/src/apriltag/apriltag_quad_thresh.hpp index 3e757aeecfe..8e425f478c9 100644 --- a/modules/aruco/src/apriltag/apriltag_quad_thresh.hpp +++ b/modules/aruco/src/apriltag/apriltag_quad_thresh.hpp @@ -20,7 +20,7 @@ #define _OPENCV_APRIL_QUAD_THRESH_HPP_ #include -#include "opencv2/aruco.hpp" +#include "opencv2/aruco_detector.hpp" #include "unionfind.hpp" #include "zmaxheap.hpp" #include "zarray.hpp" diff --git a/modules/aruco/src/aruco_detector.cpp b/modules/aruco/src/aruco_detector.cpp index aa7aad59da4..5b0e3f050d9 100644 --- a/modules/aruco/src/aruco_detector.cpp +++ b/modules/aruco/src/aruco_detector.cpp @@ -15,50 +15,6 @@ namespace aruco { using namespace std; -DetectorParameters::DetectorParameters() - : adaptiveThreshWinSizeMin(3), - adaptiveThreshWinSizeMax(23), - adaptiveThreshWinSizeStep(10), - adaptiveThreshConstant(7), - minMarkerPerimeterRate(0.03), - maxMarkerPerimeterRate(4.), - polygonalApproxAccuracyRate(0.03), - minCornerDistanceRate(0.05), - minDistanceToBorder(3), - minMarkerDistanceRate(0.05), - cornerRefinementMethod(CORNER_REFINE_NONE), - cornerRefinementWinSize(5), - cornerRefinementMaxIterations(30), - cornerRefinementMinAccuracy(0.1), - markerBorderBits(1), - perspectiveRemovePixelPerCell(4), - perspectiveRemoveIgnoredMarginPerCell(0.13), - maxErroneousBitsInBorderRate(0.35), - minOtsuStdDev(5.0), - errorCorrectionRate(0.6), - aprilTagQuadDecimate(0.0), - aprilTagQuadSigma(0.0), - aprilTagMinClusterPixels(5), - aprilTagMaxNmaxima(10), - aprilTagCriticalRad( (float)(10* CV_PI /180) ), - aprilTagMaxLineFitMse(10.0), - aprilTagMinWhiteBlackDiff(5), - aprilTagDeglitch(0), - detectInvertedMarker(false), - useAruco3Detection(false), - minSideLengthCanonicalImg(32), - minMarkerLengthRatioOriginalImg(0.0) -{} - - -/** - * @brief Create a new set of DetectorParameters with default values. - */ -Ptr DetectorParameters::create() { - Ptr params = makePtr(); - return params; -} - template static inline bool readParameter(const FileNode& node, T& parameter) { @@ -832,7 +788,6 @@ static inline void findCornerInPyrImage(const float scale_init, const int closes */ void ArucoDetector::detectMarkers(InputArray _image, OutputArrayOfArrays _corners, OutputArray _ids, OutputArrayOfArrays _rejectedImgPoints) { - CV_Assert(!_image.empty()); CV_Assert(params->markerBorderBits > 0); // check that the parameters are set correctly if Aruco3 is used @@ -991,9 +946,8 @@ void ArucoDetector::refineDetectedMarkers(InputArray _image, const Ptr &_ vector< bool > alreadyIdentified(_rejectedCorners.total(), false); // maximum bits that can be corrected - Dictionary &dictionary = *(_board->dictionary); int maxCorrectionRecalculated = - int(double(dictionary.maxCorrectionBits) * refineParams->errorCorrectionRate); + int(double(dictionary->maxCorrectionBits) * refineParams->errorCorrectionRate); Mat grey; _convertToGrey(_image, grey); @@ -1061,7 +1015,7 @@ void ArucoDetector::refineDetectedMarkers(InputArray _image, const Ptr &_ // extract bits Mat bits = _extractBits( - grey, rotatedMarker, dictionary.markerSize, params->markerBorderBits, + grey, rotatedMarker, dictionary->markerSize, params->markerBorderBits, params->perspectiveRemovePixelPerCell, params->perspectiveRemoveIgnoredMarginPerCell, params->minOtsuStdDev); @@ -1070,7 +1024,7 @@ void ArucoDetector::refineDetectedMarkers(InputArray _image, const Ptr &_ .colRange(params->markerBorderBits, bits.rows - params->markerBorderBits); codeDistance = - dictionary.getDistanceToId(onlyBits, undetectedMarkersIds[i], false); + dictionary->getDistanceToId(onlyBits, undetectedMarkersIds[i], false); } // if everythin is ok, assign values to current best match diff --git a/modules/aruco/test/test_arucodetection.cpp b/modules/aruco/test/test_arucodetection.cpp index c2715cf2d51..78ec99cc054 100644 --- a/modules/aruco/test/test_arucodetection.cpp +++ b/modules/aruco/test/test_arucodetection.cpp @@ -57,8 +57,7 @@ CV_ArucoDetectionSimple::CV_ArucoDetectionSimple() {} void CV_ArucoDetectionSimple::run(int) { - - Ptr dictionary = aruco::getPredefinedDictionary(aruco::DICT_6X6_250); + aruco::ArucoDetector detector(aruco::getPredefinedDictionary(aruco::DICT_6X6_250)); // 20 images for(int i = 0; i < 20; i++) { @@ -74,7 +73,7 @@ void CV_ArucoDetectionSimple::run(int) { for(int x = 0; x < 2; x++) { Mat marker; int id = i * 4 + y * 2 + x; - aruco::drawMarker(dictionary, id, markerSidePixels, marker); + aruco::drawMarker(detector.dictionary, id, markerSidePixels, marker); Point2f firstCorner = Point2f(markerSidePixels / 2.f + x * (1.5f * markerSidePixels), markerSidePixels / 2.f + y * (1.5f * markerSidePixels)); @@ -95,9 +94,8 @@ void CV_ArucoDetectionSimple::run(int) { // detect markers vector< vector< Point2f > > corners; vector< int > ids; - Ptr params = aruco::DetectorParameters::create(); - aruco::detectMarkers(img, dictionary, corners, ids, params); + detector.detectMarkers(img, corners, ids); // check detection results for(unsigned int m = 0; m < groundTruthIds.size(); m++) { @@ -277,7 +275,9 @@ void CV_ArucoDetectionPerspective::run(int) { cameraMatrix.at< double >(0, 0) = cameraMatrix.at< double >(1, 1) = 650; cameraMatrix.at< double >(0, 2) = imgSize.width / 2; cameraMatrix.at< double >(1, 2) = imgSize.height / 2; - Ptr dictionary = aruco::getPredefinedDictionary(aruco::DICT_6X6_250); + Ptr params = aruco::DetectorParameters::create(); + params->minDistanceToBorder = 1; + aruco::ArucoDetector detector(aruco::getPredefinedDictionary(aruco::DICT_6X6_250), params); // detect from different positions for(double distance = 0.1; distance < 0.7; distance += 0.2) { @@ -288,13 +288,11 @@ void CV_ArucoDetectionPerspective::run(int) { iter++; vector< Point2f > groundTruthCorners; - Ptr params = aruco::DetectorParameters::create(); - params->minDistanceToBorder = 1; params->markerBorderBits = markerBorder; /// create synthetic image Mat img= - projectMarker(dictionary, currentId, cameraMatrix, deg2rad(yaw), deg2rad(pitch), + projectMarker(detector.dictionary, currentId, cameraMatrix, deg2rad(yaw), deg2rad(pitch), distance, imgSize, markerBorder, groundTruthCorners, szEnclosed); // marker :: Inverted if(ArucoAlgParams::DETECT_INVERTED_MARKER == arucoAlgParams){ @@ -314,7 +312,7 @@ void CV_ArucoDetectionPerspective::run(int) { // detect markers vector< vector< Point2f > > corners; vector< int > ids; - aruco::detectMarkers(img, dictionary, corners, ids, params); + detector.detectMarkers(img, corners, ids); // check results if(ids.size() != 1 || (ids.size() == 1 && ids[0] != currentId)) { @@ -360,8 +358,8 @@ CV_ArucoDetectionMarkerSize::CV_ArucoDetectionMarkerSize() {} void CV_ArucoDetectionMarkerSize::run(int) { - - Ptr dictionary = aruco::getPredefinedDictionary(aruco::DICT_6X6_250); + Ptr params = aruco::DetectorParameters::create(); + aruco::ArucoDetector detector(aruco::getPredefinedDictionary(aruco::DICT_6X6_250), params); int markerSide = 20; int imageSize = 200; @@ -372,17 +370,16 @@ void CV_ArucoDetectionMarkerSize::run(int) { // create synthetic image Mat img = Mat(imageSize, imageSize, CV_8UC1, Scalar::all(255)); - aruco::drawMarker(dictionary, id, markerSide, marker); + aruco::drawMarker(detector.dictionary, id, markerSide, marker); Mat aux = img.colRange(30, 30 + markerSide).rowRange(50, 50 + markerSide); marker.copyTo(aux); vector< vector< Point2f > > corners; vector< int > ids; - Ptr params = aruco::DetectorParameters::create(); // set a invalid minMarkerPerimeterRate params->minMarkerPerimeterRate = min(4., (4. * markerSide) / float(imageSize) + 0.1); - aruco::detectMarkers(img, dictionary, corners, ids, params); + detector.detectMarkers(img, corners, ids); if(corners.size() != 0) { ts->printf(cvtest::TS::LOG, "Error in DetectorParameters::minMarkerPerimeterRate"); ts->set_failed_test_info(cvtest::TS::FAIL_BAD_ACCURACY); @@ -391,7 +388,7 @@ void CV_ArucoDetectionMarkerSize::run(int) { // set an valid minMarkerPerimeterRate params->minMarkerPerimeterRate = max(0., (4. * markerSide) / float(imageSize) - 0.1); - aruco::detectMarkers(img, dictionary, corners, ids, params); + detector.detectMarkers(img, corners, ids); if(corners.size() != 1 || (corners.size() == 1 && ids[0] != id)) { ts->printf(cvtest::TS::LOG, "Error in DetectorParameters::minMarkerPerimeterRate"); ts->set_failed_test_info(cvtest::TS::FAIL_BAD_ACCURACY); @@ -400,7 +397,7 @@ void CV_ArucoDetectionMarkerSize::run(int) { // set a invalid maxMarkerPerimeterRate params->maxMarkerPerimeterRate = min(4., (4. * markerSide) / float(imageSize) - 0.1); - aruco::detectMarkers(img, dictionary, corners, ids, params); + detector.detectMarkers(img, corners, ids); if(corners.size() != 0) { ts->printf(cvtest::TS::LOG, "Error in DetectorParameters::maxMarkerPerimeterRate"); ts->set_failed_test_info(cvtest::TS::FAIL_BAD_ACCURACY); @@ -409,7 +406,7 @@ void CV_ArucoDetectionMarkerSize::run(int) { // set an valid maxMarkerPerimeterRate params->maxMarkerPerimeterRate = max(0., (4. * markerSide) / float(imageSize) + 0.1); - aruco::detectMarkers(img, dictionary, corners, ids, params); + detector.detectMarkers(img, corners, ids); if(corners.size() != 1 || (corners.size() == 1 && ids[0] != id)) { ts->printf(cvtest::TS::LOG, "Error in DetectorParameters::maxMarkerPerimeterRate"); ts->set_failed_test_info(cvtest::TS::FAIL_BAD_ACCURACY); @@ -436,30 +433,32 @@ CV_ArucoBitCorrection::CV_ArucoBitCorrection() {} void CV_ArucoBitCorrection::run(int) { - Ptr _dictionary = aruco::getPredefinedDictionary(aruco::DICT_6X6_250); - aruco::Dictionary &dictionary = *_dictionary; - aruco::Dictionary dictionary2 = *_dictionary; + Ptr _dictionary1 = aruco::getPredefinedDictionary(aruco::DICT_6X6_250); + Ptr _dictionary2 = aruco::getPredefinedDictionary(aruco::DICT_6X6_250); + aruco::Dictionary &dictionary1 = *_dictionary1; + aruco::Dictionary &dictionary2 = *_dictionary2; + Ptr params = aruco::DetectorParameters::create(); + aruco::ArucoDetector detector1(_dictionary1, params); int markerSide = 50; int imageSize = 150; - Ptr params = aruco::DetectorParameters::create(); // 10 markers for(int l = 0; l < 10; l++) { Mat marker; int id = 10 + l * 20; - Mat currentCodeBytes = dictionary.bytesList.rowRange(id, id + 1); + Mat currentCodeBytes = dictionary1.bytesList.rowRange(id, id + 1); // 5 valid cases for(int i = 0; i < 5; i++) { // how many bit errors (the error is low enough so it can be corrected) params->errorCorrectionRate = 0.2 + i * 0.1; int errors = - (int)std::floor(dictionary.maxCorrectionBits * params->errorCorrectionRate - 1.); + (int)std::floor(dictionary1.maxCorrectionBits * params->errorCorrectionRate - 1.); // create erroneous marker in currentCodeBits Mat currentCodeBits = - aruco::Dictionary::getBitsFromByteList(currentCodeBytes, dictionary.markerSize); + aruco::Dictionary::getBitsFromByteList(currentCodeBytes, dictionary1.markerSize); for(int e = 0; e < errors; e++) { currentCodeBits.ptr< unsigned char >()[2 * e] = !currentCodeBits.ptr< unsigned char >()[2 * e]; @@ -476,7 +475,7 @@ void CV_ArucoBitCorrection::run(int) { // try to detect using original dictionary vector< vector< Point2f > > corners; vector< int > ids; - aruco::detectMarkers(img, _dictionary, corners, ids, params); + detector1.detectMarkers(img, corners, ids); if(corners.size() != 1 || (corners.size() == 1 && ids[0] != id)) { ts->printf(cvtest::TS::LOG, "Error in bit correction"); ts->set_failed_test_info(cvtest::TS::FAIL_BAD_ACCURACY); @@ -489,11 +488,11 @@ void CV_ArucoBitCorrection::run(int) { // how many bit errors (the error is too high to be corrected) params->errorCorrectionRate = 0.2 + i * 0.1; int errors = - (int)std::floor(dictionary.maxCorrectionBits * params->errorCorrectionRate + 1.); + (int)std::floor(dictionary1.maxCorrectionBits * params->errorCorrectionRate + 1.); // create erroneous marker in currentCodeBits Mat currentCodeBits = - aruco::Dictionary::getBitsFromByteList(currentCodeBytes, dictionary.markerSize); + aruco::Dictionary::getBitsFromByteList(currentCodeBytes, dictionary1.markerSize); for(int e = 0; e < errors; e++) { currentCodeBits.ptr< unsigned char >()[2 * e] = !currentCodeBits.ptr< unsigned char >()[2 * e]; @@ -502,9 +501,9 @@ void CV_ArucoBitCorrection::run(int) { // dictionary3 is only composed by the modified marker (in its original form) Ptr _dictionary3 = makePtr( dictionary2.bytesList.rowRange(id, id + 1).clone(), - dictionary.markerSize, - dictionary.maxCorrectionBits); - + dictionary1.markerSize, + dictionary1.maxCorrectionBits); + aruco::ArucoDetector detector3(_dictionary3, params); // add erroneous marker to dictionary2 in order to create the erroneous marker image Mat currentCodeBytesError = aruco::Dictionary::getByteListFromBits(currentCodeBits); currentCodeBytesError.copyTo(dictionary2.bytesList.rowRange(id, id + 1)); @@ -516,7 +515,7 @@ void CV_ArucoBitCorrection::run(int) { // try to detect using dictionary3, it should fail vector< vector< Point2f > > corners; vector< int > ids; - aruco::detectMarkers(img, _dictionary3, corners, ids, params); + detector3.detectMarkers(img, corners, ids); if(corners.size() != 0) { ts->printf(cvtest::TS::LOG, "Error in DetectorParameters::errorCorrectionRate"); ts->set_failed_test_info(cvtest::TS::FAIL_BAD_ACCURACY); @@ -569,8 +568,7 @@ TEST(CV_ArucoTutorial, can_find_singlemarkersoriginal) { string img_path = cvtest::findDataFile("singlemarkersoriginal.jpg", false); Mat image = imread(img_path); - Ptr dictionary = aruco::getPredefinedDictionary(aruco::DICT_6X6_250); - Ptr detectorParams = aruco::DetectorParameters::create(); + aruco::ArucoDetector detector(aruco::getPredefinedDictionary(aruco::DICT_6X6_250)); vector< int > ids; vector< vector< Point2f > > corners, rejected; @@ -584,7 +582,7 @@ TEST(CV_ArucoTutorial, can_find_singlemarkersoriginal) for (size_t i = 0; i < N; i++) mapGoldCorners[goldCornersIds[i]] = goldCorners[i]; - aruco::detectMarkers(image, dictionary, corners, ids, detectorParams, rejected); + detector.detectMarkers(image, corners, ids, rejected); ASSERT_EQ(N, ids.size()); for (size_t i = 0; i < N; i++) @@ -609,9 +607,10 @@ TEST(CV_ArucoTutorial, can_find_gboriginal) FileStorage fs(dictPath, FileStorage::READ); dictionary->aruco::Dictionary::readDictionary(fs.root()); // set marker from tutorial_dict.yml - Ptr detectorParams = aruco::DetectorParameters::create(); + aruco::ArucoDetector detector(dictionary, detectorParams); + vector< int > ids; vector< vector< Point2f > > corners, rejected; const size_t N = 35ull; @@ -638,7 +637,7 @@ TEST(CV_ArucoTutorial, can_find_gboriginal) for (int i = 0; i < static_cast(N); i++) mapGoldCorners[i] = goldCorners[i]; - aruco::detectMarkers(image, dictionary, corners, ids, detectorParams, rejected); + detector.detectMarkers(image, corners, ids, rejected); ASSERT_EQ(N, ids.size()); @@ -657,8 +656,7 @@ TEST(CV_ArucoTutorial, can_find_gboriginal) TEST(CV_ArucoDetectMarkers, regression_3192) { - Ptr dictionary = aruco::getPredefinedDictionary(aruco::DICT_4X4_50); - Ptr detectorParams = aruco::DetectorParameters::create(); + aruco::ArucoDetector detector(aruco::getPredefinedDictionary(aruco::DICT_4X4_50)); vector< int > markerIds; vector > markerCorners; string imgPath = cvtest::findDataFile("aruco/regression_3192.png"); @@ -670,7 +668,7 @@ TEST(CV_ArucoDetectMarkers, regression_3192) for (size_t i = 0; i < N; i++) mapGoldCorners[goldCornersIds[i]] = goldCorners[i]; - aruco::detectMarkers(image, dictionary, markerCorners, markerIds, detectorParams); + detector.detectMarkers(image, markerCorners, markerIds); ASSERT_EQ(N, markerIds.size()); for (size_t i = 0; i < N; i++) @@ -688,9 +686,8 @@ TEST(CV_ArucoDetectMarkers, regression_3192) TEST(CV_ArucoDetectMarkers, regression_2492) { - Ptr dictionary = aruco::getPredefinedDictionary(aruco::DICT_5X5_50); - Ptr detectorParams = aruco::DetectorParameters::create(); - detectorParams->minMarkerDistanceRate = 0.026; + aruco::ArucoDetector detector(aruco::getPredefinedDictionary(aruco::DICT_5X5_50)); + detector.params->minMarkerDistanceRate = 0.026; vector< int > markerIds; vector > markerCorners; string imgPath = cvtest::findDataFile("aruco/regression_2492.png"); @@ -705,7 +702,7 @@ TEST(CV_ArucoDetectMarkers, regression_2492) for (size_t i = 0; i < N; i++) mapGoldCorners[goldCornersIds[i]].push_back(goldCorners[i]); - aruco::detectMarkers(image, dictionary, markerCorners, markerIds, detectorParams); + detector.detectMarkers(image, markerCorners, markerIds); ASSERT_EQ(N, markerIds.size()); for (size_t i = 0; i < N; i++) @@ -746,11 +743,10 @@ struct ArucoThreading: public testing::TestWithParam params = cv::aruco::DetectorParameters::create(); // We are not testing against different dictionaries // As we are interested mostly in small images, smaller // markers is better -> 4x4 - cv::Ptr dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_4X4_50); + aruco::ArucoDetector detector(aruco::getPredefinedDictionary(aruco::DICT_4X4_50)); // Height of the test image can be chosen quite freely // We aim to test against small images as in those the @@ -762,19 +758,19 @@ TEST_P(ArucoThreading, number_of_threads_does_not_change_results) // Create a test image cv::Mat img_marker; - cv::aruco::drawMarker(dictionary, 23, height_marker, img_marker, 1); + cv::aruco::drawMarker(detector.dictionary, 23, height_marker, img_marker, 1); // Copy to bigger image to get a white border cv::Mat img(height_img, height_img, CV_8UC1, cv::Scalar(255)); img_marker.copyTo(img(cv::Rect(shift, shift, height_marker, height_marker))); - params->cornerRefinementMethod = GetParam(); + detector.params->cornerRefinementMethod = GetParam(); std::vector > original_corners; std::vector original_ids; { NumThreadsSetter thread_num_setter(1); - cv::aruco::detectMarkers(img, dictionary, original_corners, original_ids, params); + detector.detectMarkers(img, original_corners, original_ids); } ASSERT_EQ(original_ids.size(), 1ull); @@ -787,7 +783,7 @@ TEST_P(ArucoThreading, number_of_threads_does_not_change_results) std::vector > corners; std::vector ids; - cv::aruco::detectMarkers(img, dictionary, corners, ids, params); + detector.detectMarkers(img, corners, ids); // If we don't find any markers, the test is broken ASSERT_EQ(ids.size(), 1ull); diff --git a/modules/aruco/test/test_boarddetection.cpp b/modules/aruco/test/test_boarddetection.cpp index ed4ee161719..42ab71ce697 100644 --- a/modules/aruco/test/test_boarddetection.cpp +++ b/modules/aruco/test/test_boarddetection.cpp @@ -55,6 +55,8 @@ class CV_ArucoBoardPose : public cvtest::BaseTest { public: CV_ArucoBoardPose(ArucoAlgParams arucoAlgParams) { + Ptr params; + Ptr dictionary = aruco::getPredefinedDictionary(aruco::DICT_6X6_250); params = aruco::DetectorParameters::create(); params->minDistanceToBorder = 3; if (arucoAlgParams == ArucoAlgParams::USE_ARUCO3) { @@ -63,10 +65,11 @@ class CV_ArucoBoardPose : public cvtest::BaseTest { params->minSideLengthCanonicalImg = 16; params->errorCorrectionRate = 0.8; } + detector = aruco::ArucoDetector(dictionary, params); } protected: - Ptr params; + aruco::ArucoDetector detector; void run(int); }; @@ -75,8 +78,7 @@ void CV_ArucoBoardPose::run(int) { int iter = 0; Mat cameraMatrix = Mat::eye(3, 3, CV_64FC1); Size imgSize(500, 500); - Ptr dictionary = aruco::getPredefinedDictionary(aruco::DICT_6X6_250); - Ptr gridboard = aruco::GridBoard::create(3, 3, 0.02f, 0.005f, dictionary); + Ptr gridboard = aruco::GridBoard::create(3, 3, 0.02f, 0.005f, detector.dictionary); Ptr board = gridboard.staticCast(); cameraMatrix.at< double >(0, 0) = cameraMatrix.at< double >(1, 1) = 650; cameraMatrix.at< double >(0, 2) = imgSize.width / 2; @@ -96,8 +98,8 @@ void CV_ArucoBoardPose::run(int) { imgSize, markerBorder); vector< vector< Point2f > > corners; vector< int > ids; - params->markerBorderBits = markerBorder; - aruco::detectMarkers(img, dictionary, corners, ids, params); + detector.params->markerBorderBits = markerBorder; + detector.detectMarkers(img, corners, ids); ASSERT_EQ(ids.size(), gridboard->ids.size()); @@ -160,15 +162,18 @@ class CV_ArucoRefine : public cvtest::BaseTest { public: CV_ArucoRefine(ArucoAlgParams arucoAlgParams) { - params = aruco::DetectorParameters::create(); + Ptr dictionary = aruco::getPredefinedDictionary(aruco::DICT_6X6_250); + Ptr params = aruco::DetectorParameters::create(); params->minDistanceToBorder = 3; params->cornerRefinementMethod = aruco::CORNER_REFINE_SUBPIX; if (arucoAlgParams == ArucoAlgParams::USE_ARUCO3) params->useAruco3Detection = true; + Ptr refineParams = makePtr(10, 3., true); + detector = aruco::ArucoDetector(dictionary, params, refineParams); } protected: - Ptr params; + aruco::ArucoDetector detector; void run(int); }; @@ -178,8 +183,7 @@ void CV_ArucoRefine::run(int) { int iter = 0; Mat cameraMatrix = Mat::eye(3, 3, CV_64FC1); Size imgSize(500, 500); - Ptr dictionary = aruco::getPredefinedDictionary(aruco::DICT_6X6_250); - Ptr gridboard = aruco::GridBoard::create(3, 3, 0.02f, 0.005f, dictionary); + Ptr gridboard = aruco::GridBoard::create(3, 3, 0.02f, 0.005f, detector.dictionary); Ptr board = gridboard.staticCast(); cameraMatrix.at< double >(0, 0) = cameraMatrix.at< double >(1, 1) = 650; cameraMatrix.at< double >(0, 2) = imgSize.width / 2; @@ -201,8 +205,8 @@ void CV_ArucoRefine::run(int) { // detect markers vector< vector< Point2f > > corners, rejected; vector< int > ids; - params->markerBorderBits = markerBorder; - aruco::detectMarkers(img, dictionary, corners, ids, params, rejected); + detector.params->markerBorderBits = markerBorder; + detector.detectMarkers(img, corners, ids, rejected); // remove a marker from detection int markersBeforeDelete = (int)ids.size(); @@ -213,8 +217,8 @@ void CV_ArucoRefine::run(int) { ids.erase(ids.begin(), ids.begin() + 1); // try to refind the erased marker - aruco::refineDetectedMarkers(img, board, corners, ids, rejected, cameraMatrix, - distCoeffs, 10, 3., true, noArray(), params); + detector.refineDetectedMarkers(img, board, corners, ids, rejected, cameraMatrix, + distCoeffs, noArray()); // check result if((int)ids.size() < markersBeforeDelete) { diff --git a/modules/aruco/test/test_charucodetection.cpp b/modules/aruco/test/test_charucodetection.cpp index 08e289b99db..a958fb67406 100644 --- a/modules/aruco/test/test_charucodetection.cpp +++ b/modules/aruco/test/test_charucodetection.cpp @@ -132,8 +132,10 @@ void CV_CharucoDetection::run(int) { int iter = 0; Mat cameraMatrix = Mat::eye(3, 3, CV_64FC1); Size imgSize(500, 500); - Ptr dictionary = aruco::getPredefinedDictionary(aruco::DICT_6X6_250); - Ptr board = aruco::CharucoBoard::create(4, 4, 0.03f, 0.015f, dictionary); + Ptr params = aruco::DetectorParameters::create(); + params->minDistanceToBorder = 3; + aruco::ArucoDetector detector(aruco::getPredefinedDictionary(aruco::DICT_6X6_250), params); + Ptr board = aruco::CharucoBoard::create(4, 4, 0.03f, 0.015f, detector.dictionary); cameraMatrix.at< double >(0, 0) = cameraMatrix.at< double >(1, 1) = 600; cameraMatrix.at< double >(0, 2) = imgSize.width / 2; @@ -157,10 +159,9 @@ void CV_CharucoDetection::run(int) { // detect markers vector< vector< Point2f > > corners; vector< int > ids; - Ptr params = aruco::DetectorParameters::create(); - params->minDistanceToBorder = 3; - params->markerBorderBits = markerBorder; - aruco::detectMarkers(img, dictionary, corners, ids, params); + + detector.params->markerBorderBits = markerBorder; + detector.detectMarkers(img, corners, ids); if(ids.size() == 0) { ts->printf(cvtest::TS::LOG, "Marker detection failed"); @@ -237,8 +238,10 @@ void CV_CharucoPoseEstimation::run(int) { int iter = 0; Mat cameraMatrix = Mat::eye(3, 3, CV_64FC1); Size imgSize(500, 500); - Ptr dictionary = aruco::getPredefinedDictionary(aruco::DICT_6X6_250); - Ptr board = aruco::CharucoBoard::create(4, 4, 0.03f, 0.015f, dictionary); + Ptr params = aruco::DetectorParameters::create(); + params->minDistanceToBorder = 3; + aruco::ArucoDetector detector(aruco::getPredefinedDictionary(aruco::DICT_6X6_250), params); + Ptr board = aruco::CharucoBoard::create(4, 4, 0.03f, 0.015f, detector.dictionary); cameraMatrix.at< double >(0, 0) = cameraMatrix.at< double >(1, 1) = 650; cameraMatrix.at< double >(0, 2) = imgSize.width / 2; @@ -261,10 +264,8 @@ void CV_CharucoPoseEstimation::run(int) { // detect markers vector< vector< Point2f > > corners; vector< int > ids; - Ptr params = aruco::DetectorParameters::create(); - params->minDistanceToBorder = 3; - params->markerBorderBits = markerBorder; - aruco::detectMarkers(img, dictionary, corners, ids, params); + detector.params->markerBorderBits = markerBorder; + detector.detectMarkers(img, corners, ids); ASSERT_EQ(ids.size(), board->ids.size()); @@ -348,11 +349,13 @@ void CV_CharucoDiamondDetection::run(int) { int iter = 0; Mat cameraMatrix = Mat::eye(3, 3, CV_64FC1); Size imgSize(500, 500); - Ptr dictionary = aruco::getPredefinedDictionary(aruco::DICT_6X6_250); + Ptr params = aruco::DetectorParameters::create(); + params->minDistanceToBorder = 0; + aruco::ArucoDetector detector(aruco::getPredefinedDictionary(aruco::DICT_6X6_250), params); float squareLength = 0.03f; float markerLength = 0.015f; Ptr board = - aruco::CharucoBoard::create(3, 3, squareLength, markerLength, dictionary); + aruco::CharucoBoard::create(3, 3, squareLength, markerLength, detector.dictionary); cameraMatrix.at< double >(0, 0) = cameraMatrix.at< double >(1, 1) = 650; cameraMatrix.at< double >(0, 2) = imgSize.width / 2; @@ -377,10 +380,8 @@ void CV_CharucoDiamondDetection::run(int) { // detect markers vector< vector< Point2f > > corners; vector< int > ids; - Ptr params = aruco::DetectorParameters::create(); - params->minDistanceToBorder = 0; - params->markerBorderBits = markerBorder; - aruco::detectMarkers(img, dictionary, corners, ids, params); + detector.params->markerBorderBits = markerBorder; + detector.detectMarkers(img, corners, ids); if(ids.size() != 4) { ts->printf(cvtest::TS::LOG, "Not enough markers for diamond detection"); @@ -644,10 +645,12 @@ TEST(Charuco, testBoardSubpixelCoords) auto params = cv::aruco::DetectorParameters::create(); params->cornerRefinementMethod = cv::aruco::CORNER_REFINE_APRILTAG; + aruco::ArucoDetector detector(dict, params); + std::vector ids; std::vector> corners, rejected; - cv::aruco::detectMarkers(gray, dict, corners, ids, params, rejected); + detector.detectMarkers(gray, corners, ids, rejected); ASSERT_EQ(ids.size(), size_t(8)); @@ -669,8 +672,7 @@ TEST(CV_ArucoTutorial, can_find_choriginal) { string imgPath = cvtest::findDataFile("choriginal.jpg", false); Mat image = imread(imgPath); - cv::Ptr dictionary = aruco::getPredefinedDictionary(aruco::DICT_6X6_250); - Ptr detectorParams = aruco::DetectorParameters::create(); + aruco::ArucoDetector detector(aruco::getPredefinedDictionary(aruco::DICT_6X6_250)); vector< int > ids; vector< vector< Point2f > > corners, rejected; @@ -689,7 +691,7 @@ TEST(CV_ArucoTutorial, can_find_choriginal) for (int i = 0; i < static_cast(N); i++) mapGoldCorners[i] = goldCorners[i]; - aruco::detectMarkers(image, dictionary, corners, ids, detectorParams, rejected); + detector.detectMarkers(image, corners, ids, rejected); ASSERT_EQ(N, ids.size()); for (size_t i = 0; i < N; i++) @@ -709,8 +711,7 @@ TEST(CV_ArucoTutorial, can_find_chocclusion) { string imgPath = cvtest::findDataFile("chocclusion_original.jpg", false); Mat image = imread(imgPath); - cv::Ptr dictionary = aruco::getPredefinedDictionary(aruco::DICT_6X6_250); - Ptr detectorParams = aruco::DetectorParameters::create(); + aruco::ArucoDetector detector(aruco::getPredefinedDictionary(aruco::DICT_6X6_250)); vector< int > ids; vector< vector< Point2f > > corners, rejected; @@ -728,7 +729,7 @@ TEST(CV_ArucoTutorial, can_find_chocclusion) for (int i = 0; i < static_cast(N); i++) mapGoldCorners[goldCornersIds[i]] = goldCorners[i]; - aruco::detectMarkers(image, dictionary, corners, ids, detectorParams, rejected); + detector.detectMarkers(image, corners, ids, rejected); ASSERT_EQ(N, ids.size()); for (size_t i = 0; i < N; i++) @@ -760,6 +761,8 @@ TEST(CV_ArucoTutorial, can_find_diamondmarkers) detectorParams->readDetectorParameters(fs.root()); detectorParams->cornerRefinementMethod = 3; + aruco::ArucoDetector detector(dictionary, detectorParams); + vector< int > ids; vector< vector< Point2f > > corners, rejected; const size_t N = 12ull; @@ -769,7 +772,7 @@ TEST(CV_ArucoTutorial, can_find_diamondmarkers) for (int i = 0; i < static_cast(N); i++) counterGoldCornersIds[goldCornersIds[i]]++; - aruco::detectMarkers(image, dictionary, corners, ids, detectorParams, rejected); + detector.detectMarkers(image, corners, ids, rejected); map counterRes; for (size_t i = 0; i < N; i++) { @@ -786,16 +789,16 @@ TEST(Charuco, issue_14014) string imgPath = cvtest::findDataFile("aruco/recover.png"); Mat img = imread(imgPath); - Ptr dict = aruco::getPredefinedDictionary(aruco::PREDEFINED_DICTIONARY_NAME(cv::aruco::DICT_7X7_250)); - Ptr board = aruco::CharucoBoard::create(8, 5, 0.03455f, 0.02164f, dict); Ptr detectorParams = aruco::DetectorParameters::create(); detectorParams->cornerRefinementMethod = aruco::CORNER_REFINE_SUBPIX; detectorParams->cornerRefinementMinAccuracy = 0.01; + aruco::ArucoDetector detector(aruco::getPredefinedDictionary(aruco::DICT_7X7_250), detectorParams); + Ptr board = aruco::CharucoBoard::create(8, 5, 0.03455f, 0.02164f, detector.dictionary); vector corners, rejectedPoints; vector ids; - aruco::detectMarkers(img, dict, corners, ids, detectorParams, rejectedPoints); + detector.detectMarkers(img, corners, ids, rejectedPoints); ASSERT_EQ(corners.size(), 19ull); EXPECT_EQ(Size(4, 1), corners[0].size()); // check dimension of detected corners @@ -804,7 +807,7 @@ TEST(Charuco, issue_14014) ASSERT_EQ(rejectedPoints.size(), 26ull); // optional check to track regressions EXPECT_EQ(Size(4, 1), rejectedPoints[0].size()); // check dimension of detected corners - aruco::refineDetectedMarkers(img, board, corners, ids, rejectedPoints); + detector.refineDetectedMarkers(img, board, corners, ids, rejectedPoints); ASSERT_EQ(corners.size(), 20ull); EXPECT_EQ(Size(4, 1), corners[0].size()); // check dimension of rejected corners after successfully refine diff --git a/modules/aruco/test/test_precomp.hpp b/modules/aruco/test/test_precomp.hpp index d8c903f4c7b..86595ccbda8 100644 --- a/modules/aruco/test/test_precomp.hpp +++ b/modules/aruco/test/test_precomp.hpp @@ -7,7 +7,6 @@ #include "opencv2/ts.hpp" #include "opencv2/imgproc.hpp" #include "opencv2/calib3d.hpp" -#include "opencv2/aruco.hpp" #include #endif diff --git a/modules/ovis/samples/aruco_ar_demo.cpp b/modules/ovis/samples/aruco_ar_demo.cpp index 8e2464046c1..2398a7182a3 100644 --- a/modules/ovis/samples/aruco_ar_demo.cpp +++ b/modules/ovis/samples/aruco_ar_demo.cpp @@ -3,7 +3,7 @@ #include #include -#include +#include #include