36 #include <visp3/core/vpConfig.h> 38 #if defined(VISP_HAVE_CATCH2) 39 #define CATCH_CONFIG_ENABLE_BENCHMARKING 40 #define CATCH_CONFIG_RUNNER 43 #include <visp3/core/vpIoTools.h> 44 #include <visp3/detection/vpDetectorAprilTag.h> 45 #include <visp3/io/vpImageIo.h> 47 TEST_CASE(
"Benchmark Apriltag detection 1920x1080",
"[benchmark]") {
48 const double tagSize = 0.25;
50 const size_t nbTags = 5;
55 "AprilTag/benchmark/1920x1080/tag16_05_1920x1080.png");
61 BENCHMARK(
"Benchmark Apriltag detection: tag16_05 1920x1080") {
62 std::vector<vpHomogeneousMatrix> cMo_vec;
63 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
64 CHECK(cMo_vec.size() == nbTags);
68 apriltag_detector.setAprilTagQuadDecimate(2);
69 BENCHMARK(
"Benchmark Apriltag detection: tag16_05 1920x1080 decimate=2") {
70 std::vector<vpHomogeneousMatrix> cMo_vec;
71 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
72 CHECK(cMo_vec.size() == nbTags);
76 apriltag_detector.setAprilTagQuadDecimate(3);
77 BENCHMARK(
"Benchmark Apriltag detection: tag16_05 1920x1080 decimate=3") {
78 std::vector<vpHomogeneousMatrix> cMo_vec;
79 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
80 CHECK(cMo_vec.size() == nbTags);
88 "AprilTag/benchmark/1920x1080/tag25_09_1920x1080.png");
94 BENCHMARK(
"Benchmark Apriltag detection: tag25_09 1920x1080") {
95 std::vector<vpHomogeneousMatrix> cMo_vec;
96 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
97 CHECK(cMo_vec.size() == nbTags);
101 apriltag_detector.setAprilTagQuadDecimate(2);
102 BENCHMARK(
"Benchmark Apriltag detection: tag25_09 1920x1080 decimate=2") {
103 std::vector<vpHomogeneousMatrix> cMo_vec;
104 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
105 CHECK(cMo_vec.size() == nbTags);
109 apriltag_detector.setAprilTagQuadDecimate(3);
110 BENCHMARK(
"Benchmark Apriltag detection: tag25_09 1920x1080 decimate=3") {
111 std::vector<vpHomogeneousMatrix> cMo_vec;
112 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
113 CHECK(cMo_vec.size() == nbTags);
121 "AprilTag/benchmark/1920x1080/tag36_11_1920x1080.png");
127 BENCHMARK(
"Benchmark Apriltag detection: tag36_11 1920x1080") {
128 std::vector<vpHomogeneousMatrix> cMo_vec;
129 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
130 CHECK(cMo_vec.size() == nbTags);
134 apriltag_detector.setAprilTagQuadDecimate(2);
135 BENCHMARK(
"Benchmark Apriltag detection: tag36_11 1920x1080 decimate=2") {
136 std::vector<vpHomogeneousMatrix> cMo_vec;
137 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
138 CHECK(cMo_vec.size() == nbTags);
142 apriltag_detector.setAprilTagQuadDecimate(3);
143 BENCHMARK(
"Benchmark Apriltag detection: tag36_11 1920x1080 decimate=3") {
144 std::vector<vpHomogeneousMatrix> cMo_vec;
145 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
146 CHECK(cMo_vec.size() == nbTags);
154 "AprilTag/benchmark/1920x1080/tag21_07_1920x1080.png");
160 BENCHMARK(
"Benchmark Apriltag detection: tag21_07 1920x1080") {
161 std::vector<vpHomogeneousMatrix> cMo_vec;
162 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
163 CHECK(cMo_vec.size() == nbTags);
167 apriltag_detector.setAprilTagQuadDecimate(2);
168 BENCHMARK(
"Benchmark Apriltag detection: tag21_07 1920x1080 decimate=2") {
169 std::vector<vpHomogeneousMatrix> cMo_vec;
170 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
171 CHECK(cMo_vec.size() == nbTags);
175 apriltag_detector.setAprilTagQuadDecimate(3);
176 BENCHMARK(
"Benchmark Apriltag detection: tag21_07 1920x1080 decimate=3") {
177 std::vector<vpHomogeneousMatrix> cMo_vec;
178 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
179 CHECK(cMo_vec.size() == nbTags);
184 #if defined(VISP_HAVE_APRILTAG_BIG_FAMILY) 188 "AprilTag/benchmark/1920x1080/tag49_12_1920x1080.png");
194 BENCHMARK(
"Benchmark Apriltag detection: tag49_12 1920x1080") {
195 std::vector<vpHomogeneousMatrix> cMo_vec;
196 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
197 CHECK(cMo_vec.size() == nbTags);
201 apriltag_detector.setAprilTagQuadDecimate(2);
202 BENCHMARK(
"Benchmark Apriltag detection: tag49_12 1920x1080 decimate=2") {
203 std::vector<vpHomogeneousMatrix> cMo_vec;
204 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
205 CHECK(cMo_vec.size() == nbTags);
209 apriltag_detector.setAprilTagQuadDecimate(3);
210 BENCHMARK(
"Benchmark Apriltag detection: tag49_12 1920x1080 decimate=3") {
211 std::vector<vpHomogeneousMatrix> cMo_vec;
212 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
213 CHECK(cMo_vec.size() == nbTags);
221 "AprilTag/benchmark/1920x1080/tag48_12_1920x1080.png");
227 BENCHMARK(
"Benchmark Apriltag detection: tag48_12 1920x1080") {
228 std::vector<vpHomogeneousMatrix> cMo_vec;
229 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
230 CHECK(cMo_vec.size() == nbTags);
234 apriltag_detector.setAprilTagQuadDecimate(2);
235 BENCHMARK(
"Benchmark Apriltag detection: tag48_12 1920x1080 decimate=2") {
236 std::vector<vpHomogeneousMatrix> cMo_vec;
237 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
238 CHECK(cMo_vec.size() == nbTags);
242 apriltag_detector.setAprilTagQuadDecimate(3);
243 BENCHMARK(
"Benchmark Apriltag detection: tag48_12 1920x1080 decimate=3") {
244 std::vector<vpHomogeneousMatrix> cMo_vec;
245 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
246 CHECK(cMo_vec.size() == nbTags);
254 "AprilTag/benchmark/1920x1080/tag41_12_1920x1080.png");
260 BENCHMARK(
"Benchmark Apriltag detection: tag41_12 1920x1080") {
261 std::vector<vpHomogeneousMatrix> cMo_vec;
262 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
263 CHECK(cMo_vec.size() == nbTags);
267 apriltag_detector.setAprilTagQuadDecimate(2);
268 BENCHMARK(
"Benchmark Apriltag detection: tag41_12 1920x1080 decimate=2") {
269 std::vector<vpHomogeneousMatrix> cMo_vec;
270 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
271 CHECK(cMo_vec.size() == nbTags);
275 apriltag_detector.setAprilTagQuadDecimate(3);
276 BENCHMARK(
"Benchmark Apriltag detection: tag41_12 1920x1080 decimate=3") {
277 std::vector<vpHomogeneousMatrix> cMo_vec;
278 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
279 CHECK(cMo_vec.size() == nbTags);
287 "AprilTag/benchmark/1920x1080/tag52_13_1920x1080.png");
293 BENCHMARK(
"Benchmark Apriltag detection: tag52_13 1920x1080") {
294 std::vector<vpHomogeneousMatrix> cMo_vec;
295 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
296 CHECK(cMo_vec.size() == nbTags);
300 apriltag_detector.setAprilTagQuadDecimate(2);
301 BENCHMARK(
"Benchmark Apriltag detection: tag52_13 1920x1080 decimate=2") {
302 std::vector<vpHomogeneousMatrix> cMo_vec;
303 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
304 CHECK(cMo_vec.size() == nbTags);
308 apriltag_detector.setAprilTagQuadDecimate(3);
309 BENCHMARK(
"Benchmark Apriltag detection: tag52_13 1920x1080 decimate=3") {
310 std::vector<vpHomogeneousMatrix> cMo_vec;
311 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
312 CHECK(cMo_vec.size() == nbTags);
319 TEST_CASE(
"Benchmark Apriltag detection 640x480",
"[benchmark]") {
320 const double tagSize = 0.25;
322 const size_t nbTags = 5;
327 "AprilTag/benchmark/640x480/tag16_05_640x480.png");
333 BENCHMARK(
"Benchmark Apriltag detection: tag16_05 640x480") {
334 std::vector<vpHomogeneousMatrix> cMo_vec;
335 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
336 CHECK(cMo_vec.size() == nbTags);
344 "AprilTag/benchmark/640x480/tag25_09_640x480.png");
350 BENCHMARK(
"Benchmark Apriltag detection: tag25_09 640x480") {
351 std::vector<vpHomogeneousMatrix> cMo_vec;
352 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
353 CHECK(cMo_vec.size() == nbTags);
361 "AprilTag/benchmark/640x480/tag36_11_640x480.png");
367 BENCHMARK(
"Benchmark Apriltag detection: tag36_11 640x480") {
368 std::vector<vpHomogeneousMatrix> cMo_vec;
369 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
370 CHECK(cMo_vec.size() == nbTags);
378 "AprilTag/benchmark/640x480/tag21_07_640x480.png");
384 BENCHMARK(
"Benchmark Apriltag detection: tag21_07 640x480") {
385 std::vector<vpHomogeneousMatrix> cMo_vec;
386 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
387 CHECK(cMo_vec.size() == nbTags);
392 #if defined(VISP_HAVE_APRILTAG_BIG_FAMILY) 396 "AprilTag/benchmark/640x480/tag49_12_640x480.png");
402 BENCHMARK(
"Benchmark Apriltag detection: tag49_12 640x480") {
403 std::vector<vpHomogeneousMatrix> cMo_vec;
404 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
405 CHECK(cMo_vec.size() == nbTags);
413 "AprilTag/benchmark/640x480/tag48_12_640x480.png");
419 BENCHMARK(
"Benchmark Apriltag detection: tag48_12 640x480") {
420 std::vector<vpHomogeneousMatrix> cMo_vec;
421 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
422 CHECK(cMo_vec.size() == nbTags);
430 "AprilTag/benchmark/640x480/tag41_12_640x480.png");
436 BENCHMARK(
"Benchmark Apriltag detection: tag41_12 640x480") {
437 std::vector<vpHomogeneousMatrix> cMo_vec;
438 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
439 CHECK(cMo_vec.size() == nbTags);
447 "AprilTag/benchmark/640x480/tag52_13_640x480.png");
453 BENCHMARK(
"Benchmark Apriltag detection: tag52_13 640x480") {
454 std::vector<vpHomogeneousMatrix> cMo_vec;
455 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
456 CHECK(cMo_vec.size() == nbTags);
463 int main(
int argc,
char *argv[])
465 Catch::Session session;
467 bool runBenchmark =
false;
469 using namespace Catch::clara;
470 auto cli = session.cli()
479 session.applyCommandLine(argc, argv);
482 int numFailed = session.run();
AprilTag Standard52h13 pattern.
AprilTag 36h11 pattern (recommended)
AprilTag Circle21h7 pattern.
AprilTag Circle49h12 pattern.
Generic class defining intrinsic camera parameters.
AprilTag Standard41h12 pattern.
static void read(vpImage< unsigned char > &I, const std::string &filename)
AprilTag Custom48h12 pattern.