@@ -151,28 +151,35 @@ static Mat projectBoard(Ptr<aruco::GridBoard> &board, Mat cameraMatrix, double y
151151 return img;
152152}
153153
154-
154+ enum class ArucoAlgParams
155+ {
156+ USE_DEFAULT = 0 ,
157+ USE_ARUCO3 = 1
158+ };
155159
156160/* *
157161 * @brief Check pose estimation of aruco board
158162 */
159163class CV_ArucoBoardPose : public cvtest ::BaseTest {
160164 public:
161- CV_ArucoBoardPose ();
162-
163- enum checkWithParameter{
164- USE_ARUCO3 = 1 // / Check if aruco3 should be used
165- };
165+ CV_ArucoBoardPose (ArucoAlgParams arucoAlgParams)
166+ {
167+ params = aruco::DetectorParameters::create ();
168+ params->minDistanceToBorder = 3 ;
169+ if (arucoAlgParams == ArucoAlgParams::USE_ARUCO3) {
170+ params->useAruco3Detection = true ;
171+ params->cornerRefinementMethod = aruco::CORNER_REFINE_SUBPIX;
172+ params->minSideLengthCanonicalImg = 16 ;
173+ }
174+ }
166175
167176 protected:
177+ Ptr<aruco::DetectorParameters> params;
168178 void run (int );
169179};
170180
171181
172- CV_ArucoBoardPose::CV_ArucoBoardPose () {}
173-
174-
175- void CV_ArucoBoardPose::run (int run_with) {
182+ void CV_ArucoBoardPose::run (int ) {
176183
177184 int iter = 0 ;
178185 Mat cameraMatrix = Mat::eye (3 , 3 , CV_64FC1);
@@ -201,13 +208,6 @@ void CV_ArucoBoardPose::run(int run_with) {
201208
202209 vector< vector< Point2f > > corners;
203210 vector< int > ids;
204- Ptr<aruco::DetectorParameters> params = aruco::DetectorParameters::create ();
205- params->minDistanceToBorder = 3 ;
206- if (run_with == checkWithParameter::USE_ARUCO3) {
207- params->useAruco3Detection = true ;
208- params->cornerRefinementMethod = aruco::CORNER_REFINE_SUBPIX;
209- params->minSideLengthCanonicalImg = 16 ;
210- }
211211 params->markerBorderBits = markerBorder;
212212 aruco::detectMarkers (img, dictionary, corners, ids, params);
213213
@@ -262,20 +262,22 @@ void CV_ArucoBoardPose::run(int run_with) {
262262 */
263263class CV_ArucoRefine : public cvtest ::BaseTest {
264264 public:
265- CV_ArucoRefine ();
265+ CV_ArucoRefine (ArucoAlgParams arucoAlgParams)
266+ {
267+ params = aruco::DetectorParameters::create ();
268+ params->minDistanceToBorder = 3 ;
269+ params->cornerRefinementMethod = aruco::CORNER_REFINE_SUBPIX;
270+ if (arucoAlgParams == ArucoAlgParams::USE_ARUCO3)
271+ params->useAruco3Detection = true ;
272+ }
266273
267- enum checkWithParameter{
268- USE_ARUCO3 = 1 // / Check if aruco3 should be used
269- };
270274 protected:
271- void run (int run_with);
275+ Ptr<aruco::DetectorParameters> params;
276+ void run (int );
272277};
273278
274279
275- CV_ArucoRefine::CV_ArucoRefine () {}
276-
277-
278- void CV_ArucoRefine::run (int run_with) {
280+ void CV_ArucoRefine::run (int ) {
279281
280282 int iter = 0 ;
281283 Mat cameraMatrix = Mat::eye (3 , 3 , CV_64FC1);
@@ -305,12 +307,6 @@ void CV_ArucoRefine::run(int run_with) {
305307 // detect markers
306308 vector< vector< Point2f > > corners, rejected;
307309 vector< int > ids;
308- Ptr<aruco::DetectorParameters> params = aruco::DetectorParameters::create ();
309- params->minDistanceToBorder = 3 ;
310- params->cornerRefinementMethod = aruco::CORNER_REFINE_SUBPIX;
311- if (run_with == checkWithParameter::USE_ARUCO3) {
312- params->useAruco3Detection = true ;
313- }
314310 params->markerBorderBits = markerBorder;
315311 aruco::detectMarkers (img, dictionary, corners, ids, params, rejected);
316312
@@ -341,26 +337,26 @@ void CV_ArucoRefine::run(int run_with) {
341337
342338
343339TEST (CV_ArucoBoardPose, accuracy) {
344- CV_ArucoBoardPose test;
340+ CV_ArucoBoardPose test (ArucoAlgParams::USE_DEFAULT) ;
345341 test.safe_run ();
346342}
347343
348344typedef CV_ArucoBoardPose CV_Aruco3BoardPose;
349345TEST (CV_Aruco3BoardPose, accuracy) {
350- CV_Aruco3BoardPose test;
351- test.safe_run (CV_Aruco3BoardPose::checkWithParameter::USE_ARUCO3 );
346+ CV_Aruco3BoardPose test (ArucoAlgParams::USE_ARUCO3) ;
347+ test.safe_run ();
352348}
353349
354350typedef CV_ArucoRefine CV_Aruco3Refine;
355351
356352TEST (CV_ArucoRefine, accuracy) {
357- CV_ArucoRefine test;
353+ CV_ArucoRefine test (ArucoAlgParams::USE_DEFAULT) ;
358354 test.safe_run ();
359355}
360356
361357TEST (CV_Aruco3Refine, accuracy) {
362- CV_Aruco3Refine test;
363- test.safe_run (CV_Aruco3Refine::checkWithParameter::USE_ARUCO3 );
358+ CV_Aruco3Refine test (ArucoAlgParams::USE_ARUCO3) ;
359+ test.safe_run ();
364360}
365361
366362TEST (CV_ArucoBoardPose, CheckNegativeZ)
0 commit comments