Skip to content

Commit ad9c69c

Browse files
author
AleksandrPanov
committed
add ArUco params to test classes
1 parent 318edea commit ad9c69c

File tree

2 files changed

+36
-39
lines changed

2 files changed

+36
-39
lines changed

modules/aruco/src/aruco.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,8 @@ static void _identifyCandidates(InputArray grey,
704704
vector< vector< Point2f > >& _accepted, vector< vector<Point> >& _contours, vector< int >& ids,
705705
const Ptr<DetectorParameters> &params,
706706
OutputArrayOfArrays _rejected = noArray()) {
707-
707+
CV_DbgAssert(grey.getMat().total() != 0);
708+
CV_DbgAssert(grey.getMat().type() == CV_8UC1);
708709
int ncandidates = (int)_candidatesSet[0].size();
709710
vector< vector< Point2f > > accepted;
710711
vector< vector< Point2f > > rejected;

modules/aruco/test/test_boarddetection.cpp

Lines changed: 34 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -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
*/
159163
class 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
*/
263263
class 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

343339
TEST(CV_ArucoBoardPose, accuracy) {
344-
CV_ArucoBoardPose test;
340+
CV_ArucoBoardPose test(ArucoAlgParams::USE_DEFAULT);
345341
test.safe_run();
346342
}
347343

348344
typedef CV_ArucoBoardPose CV_Aruco3BoardPose;
349345
TEST(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

354350
typedef CV_ArucoRefine CV_Aruco3Refine;
355351

356352
TEST(CV_ArucoRefine, accuracy) {
357-
CV_ArucoRefine test;
353+
CV_ArucoRefine test(ArucoAlgParams::USE_DEFAULT);
358354
test.safe_run();
359355
}
360356

361357
TEST(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

366362
TEST(CV_ArucoBoardPose, CheckNegativeZ)

0 commit comments

Comments
 (0)