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]")
49 const double tagSize = 0.25;
51 const size_t nbTags = 5;
56 "AprilTag/benchmark/1920x1080/tag16_05_1920x1080.png");
62 BENCHMARK(
"Benchmark Apriltag detection: tag16_05 1920x1080")
64 std::vector<vpHomogeneousMatrix> cMo_vec;
65 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
66 CHECK(cMo_vec.size() == nbTags);
70 apriltag_detector.setAprilTagQuadDecimate(2);
71 BENCHMARK(
"Benchmark Apriltag detection: tag16_05 1920x1080 decimate=2")
73 std::vector<vpHomogeneousMatrix> cMo_vec;
74 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
75 CHECK(cMo_vec.size() == nbTags);
79 apriltag_detector.setAprilTagQuadDecimate(3);
80 BENCHMARK(
"Benchmark Apriltag detection: tag16_05 1920x1080 decimate=3")
82 std::vector<vpHomogeneousMatrix> cMo_vec;
83 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
84 CHECK(cMo_vec.size() == nbTags);
92 "AprilTag/benchmark/1920x1080/tag25_09_1920x1080.png");
98 BENCHMARK(
"Benchmark Apriltag detection: tag25_09 1920x1080")
100 std::vector<vpHomogeneousMatrix> cMo_vec;
101 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
102 CHECK(cMo_vec.size() == nbTags);
106 apriltag_detector.setAprilTagQuadDecimate(2);
107 BENCHMARK(
"Benchmark Apriltag detection: tag25_09 1920x1080 decimate=2")
109 std::vector<vpHomogeneousMatrix> cMo_vec;
110 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
111 CHECK(cMo_vec.size() == nbTags);
115 apriltag_detector.setAprilTagQuadDecimate(3);
116 BENCHMARK(
"Benchmark Apriltag detection: tag25_09 1920x1080 decimate=3")
118 std::vector<vpHomogeneousMatrix> cMo_vec;
119 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
120 CHECK(cMo_vec.size() == nbTags);
128 "AprilTag/benchmark/1920x1080/tag36_11_1920x1080.png");
134 BENCHMARK(
"Benchmark Apriltag detection: tag36_11 1920x1080")
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(2);
143 BENCHMARK(
"Benchmark Apriltag detection: tag36_11 1920x1080 decimate=2")
145 std::vector<vpHomogeneousMatrix> cMo_vec;
146 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
147 CHECK(cMo_vec.size() == nbTags);
151 apriltag_detector.setAprilTagQuadDecimate(3);
152 BENCHMARK(
"Benchmark Apriltag detection: tag36_11 1920x1080 decimate=3")
154 std::vector<vpHomogeneousMatrix> cMo_vec;
155 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
156 CHECK(cMo_vec.size() == nbTags);
164 "AprilTag/benchmark/1920x1080/tag21_07_1920x1080.png");
170 BENCHMARK(
"Benchmark Apriltag detection: tag21_07 1920x1080")
172 std::vector<vpHomogeneousMatrix> cMo_vec;
173 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
174 CHECK(cMo_vec.size() == nbTags);
178 apriltag_detector.setAprilTagQuadDecimate(2);
179 BENCHMARK(
"Benchmark Apriltag detection: tag21_07 1920x1080 decimate=2")
181 std::vector<vpHomogeneousMatrix> cMo_vec;
182 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
183 CHECK(cMo_vec.size() == nbTags);
187 apriltag_detector.setAprilTagQuadDecimate(3);
188 BENCHMARK(
"Benchmark Apriltag detection: tag21_07 1920x1080 decimate=3")
190 std::vector<vpHomogeneousMatrix> cMo_vec;
191 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
192 CHECK(cMo_vec.size() == nbTags);
197 #if defined(VISP_HAVE_APRILTAG_BIG_FAMILY)
201 "AprilTag/benchmark/1920x1080/tag49_12_1920x1080.png");
207 BENCHMARK(
"Benchmark Apriltag detection: tag49_12 1920x1080")
209 std::vector<vpHomogeneousMatrix> cMo_vec;
210 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
211 CHECK(cMo_vec.size() == nbTags);
215 apriltag_detector.setAprilTagQuadDecimate(2);
216 BENCHMARK(
"Benchmark Apriltag detection: tag49_12 1920x1080 decimate=2")
218 std::vector<vpHomogeneousMatrix> cMo_vec;
219 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
220 CHECK(cMo_vec.size() == nbTags);
224 apriltag_detector.setAprilTagQuadDecimate(3);
225 BENCHMARK(
"Benchmark Apriltag detection: tag49_12 1920x1080 decimate=3")
227 std::vector<vpHomogeneousMatrix> cMo_vec;
228 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
229 CHECK(cMo_vec.size() == nbTags);
237 "AprilTag/benchmark/1920x1080/tag48_12_1920x1080.png");
243 BENCHMARK(
"Benchmark Apriltag detection: tag48_12 1920x1080")
245 std::vector<vpHomogeneousMatrix> cMo_vec;
246 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
247 CHECK(cMo_vec.size() == nbTags);
251 apriltag_detector.setAprilTagQuadDecimate(2);
252 BENCHMARK(
"Benchmark Apriltag detection: tag48_12 1920x1080 decimate=2")
254 std::vector<vpHomogeneousMatrix> cMo_vec;
255 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
256 CHECK(cMo_vec.size() == nbTags);
260 apriltag_detector.setAprilTagQuadDecimate(3);
261 BENCHMARK(
"Benchmark Apriltag detection: tag48_12 1920x1080 decimate=3")
263 std::vector<vpHomogeneousMatrix> cMo_vec;
264 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
265 CHECK(cMo_vec.size() == nbTags);
273 "AprilTag/benchmark/1920x1080/tag41_12_1920x1080.png");
279 BENCHMARK(
"Benchmark Apriltag detection: tag41_12 1920x1080")
281 std::vector<vpHomogeneousMatrix> cMo_vec;
282 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
283 CHECK(cMo_vec.size() == nbTags);
287 apriltag_detector.setAprilTagQuadDecimate(2);
288 BENCHMARK(
"Benchmark Apriltag detection: tag41_12 1920x1080 decimate=2")
290 std::vector<vpHomogeneousMatrix> cMo_vec;
291 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
292 CHECK(cMo_vec.size() == nbTags);
296 apriltag_detector.setAprilTagQuadDecimate(3);
297 BENCHMARK(
"Benchmark Apriltag detection: tag41_12 1920x1080 decimate=3")
299 std::vector<vpHomogeneousMatrix> cMo_vec;
300 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
301 CHECK(cMo_vec.size() == nbTags);
309 "AprilTag/benchmark/1920x1080/tag52_13_1920x1080.png");
315 BENCHMARK(
"Benchmark Apriltag detection: tag52_13 1920x1080")
317 std::vector<vpHomogeneousMatrix> cMo_vec;
318 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
319 CHECK(cMo_vec.size() == nbTags);
323 apriltag_detector.setAprilTagQuadDecimate(2);
324 BENCHMARK(
"Benchmark Apriltag detection: tag52_13 1920x1080 decimate=2")
326 std::vector<vpHomogeneousMatrix> cMo_vec;
327 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
328 CHECK(cMo_vec.size() == nbTags);
332 apriltag_detector.setAprilTagQuadDecimate(3);
333 BENCHMARK(
"Benchmark Apriltag detection: tag52_13 1920x1080 decimate=3")
335 std::vector<vpHomogeneousMatrix> cMo_vec;
336 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
337 CHECK(cMo_vec.size() == nbTags);
344 TEST_CASE(
"Benchmark Apriltag detection 640x480",
"[benchmark]")
346 const double tagSize = 0.25;
348 const size_t nbTags = 5;
353 "AprilTag/benchmark/640x480/tag16_05_640x480.png");
359 BENCHMARK(
"Benchmark Apriltag detection: tag16_05 640x480")
361 std::vector<vpHomogeneousMatrix> cMo_vec;
362 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
363 CHECK(cMo_vec.size() == nbTags);
371 "AprilTag/benchmark/640x480/tag25_09_640x480.png");
377 BENCHMARK(
"Benchmark Apriltag detection: tag25_09 640x480")
379 std::vector<vpHomogeneousMatrix> cMo_vec;
380 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
381 CHECK(cMo_vec.size() == nbTags);
389 "AprilTag/benchmark/640x480/tag36_11_640x480.png");
395 BENCHMARK(
"Benchmark Apriltag detection: tag36_11 640x480")
397 std::vector<vpHomogeneousMatrix> cMo_vec;
398 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
399 CHECK(cMo_vec.size() == nbTags);
407 "AprilTag/benchmark/640x480/tag21_07_640x480.png");
413 BENCHMARK(
"Benchmark Apriltag detection: tag21_07 640x480")
415 std::vector<vpHomogeneousMatrix> cMo_vec;
416 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
417 CHECK(cMo_vec.size() == nbTags);
422 #if defined(VISP_HAVE_APRILTAG_BIG_FAMILY)
426 "AprilTag/benchmark/640x480/tag49_12_640x480.png");
432 BENCHMARK(
"Benchmark Apriltag detection: tag49_12 640x480")
434 std::vector<vpHomogeneousMatrix> cMo_vec;
435 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
436 CHECK(cMo_vec.size() == nbTags);
444 "AprilTag/benchmark/640x480/tag48_12_640x480.png");
450 BENCHMARK(
"Benchmark Apriltag detection: tag48_12 640x480")
452 std::vector<vpHomogeneousMatrix> cMo_vec;
453 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
454 CHECK(cMo_vec.size() == nbTags);
462 "AprilTag/benchmark/640x480/tag41_12_640x480.png");
468 BENCHMARK(
"Benchmark Apriltag detection: tag41_12 640x480")
470 std::vector<vpHomogeneousMatrix> cMo_vec;
471 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
472 CHECK(cMo_vec.size() == nbTags);
480 "AprilTag/benchmark/640x480/tag52_13_640x480.png");
486 BENCHMARK(
"Benchmark Apriltag detection: tag52_13 640x480")
488 std::vector<vpHomogeneousMatrix> cMo_vec;
489 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
490 CHECK(cMo_vec.size() == nbTags);
497 int main(
int argc,
char *argv[])
499 Catch::Session session;
501 bool runBenchmark =
false;
503 using namespace Catch::clara;
504 auto cli = session.cli()
513 session.applyCommandLine(argc, argv);
516 int numFailed = session.run();
527 int main() {
return EXIT_SUCCESS; }
Generic class defining intrinsic camera parameters.
@ TAG_CIRCLE21h7
AprilTag Circle21h7 pattern.
@ TAG_25h9
AprilTag 25h9 pattern.
@ TAG_CUSTOM48h12
AprilTag Custom48h12 pattern.
@ TAG_36h11
AprilTag 36h11 pattern (recommended)
@ TAG_STANDARD52h13
AprilTag Standard52h13 pattern.
@ TAG_16h5
AprilTag 16h5 pattern.
@ TAG_STANDARD41h12
AprilTag Standard41h12 pattern.
@ TAG_CIRCLE49h12
AprilTag Circle49h12 pattern.
static void read(vpImage< unsigned char > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND)