37 #include <visp3/core/vpConfig.h>
39 #if defined(VISP_HAVE_CATCH2)
41 #include <catch_amalgamated.hpp>
43 #include <visp3/core/vpIoTools.h>
44 #include <visp3/detection/vpDetectorAprilTag.h>
45 #include <visp3/io/vpImageIo.h>
47 #ifdef ENABLE_VISP_NAMESPACE
51 TEST_CASE(
"Benchmark Apriltag detection 1920x1080",
"[benchmark]")
53 const double tagSize = 0.25;
55 const size_t nbTags = 5;
60 "AprilTag/benchmark/1920x1080/tag16_05_1920x1080.png");
66 BENCHMARK(
"Benchmark Apriltag detection: tag16_05 1920x1080")
68 std::vector<vpHomogeneousMatrix> cMo_vec;
69 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
70 CHECK(cMo_vec.size() == nbTags);
74 apriltag_detector.setAprilTagQuadDecimate(2);
75 BENCHMARK(
"Benchmark Apriltag detection: tag16_05 1920x1080 decimate=2")
77 std::vector<vpHomogeneousMatrix> cMo_vec;
78 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
79 CHECK(cMo_vec.size() == nbTags);
83 apriltag_detector.setAprilTagQuadDecimate(3);
84 BENCHMARK(
"Benchmark Apriltag detection: tag16_05 1920x1080 decimate=3")
86 std::vector<vpHomogeneousMatrix> cMo_vec;
87 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
88 CHECK(cMo_vec.size() == nbTags);
96 "AprilTag/benchmark/1920x1080/tag25_09_1920x1080.png");
102 BENCHMARK(
"Benchmark Apriltag detection: tag25_09 1920x1080")
104 std::vector<vpHomogeneousMatrix> cMo_vec;
105 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
106 CHECK(cMo_vec.size() == nbTags);
110 apriltag_detector.setAprilTagQuadDecimate(2);
111 BENCHMARK(
"Benchmark Apriltag detection: tag25_09 1920x1080 decimate=2")
113 std::vector<vpHomogeneousMatrix> cMo_vec;
114 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
115 CHECK(cMo_vec.size() == nbTags);
119 apriltag_detector.setAprilTagQuadDecimate(3);
120 BENCHMARK(
"Benchmark Apriltag detection: tag25_09 1920x1080 decimate=3")
122 std::vector<vpHomogeneousMatrix> cMo_vec;
123 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
124 CHECK(cMo_vec.size() == nbTags);
132 "AprilTag/benchmark/1920x1080/tag36_11_1920x1080.png");
138 BENCHMARK(
"Benchmark Apriltag detection: tag36_11 1920x1080")
140 std::vector<vpHomogeneousMatrix> cMo_vec;
141 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
142 CHECK(cMo_vec.size() == nbTags);
146 apriltag_detector.setAprilTagQuadDecimate(2);
147 BENCHMARK(
"Benchmark Apriltag detection: tag36_11 1920x1080 decimate=2")
149 std::vector<vpHomogeneousMatrix> cMo_vec;
150 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
151 CHECK(cMo_vec.size() == nbTags);
155 apriltag_detector.setAprilTagQuadDecimate(3);
156 BENCHMARK(
"Benchmark Apriltag detection: tag36_11 1920x1080 decimate=3")
158 std::vector<vpHomogeneousMatrix> cMo_vec;
159 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
160 CHECK(cMo_vec.size() == nbTags);
168 "AprilTag/benchmark/1920x1080/tag21_07_1920x1080.png");
174 BENCHMARK(
"Benchmark Apriltag detection: tag21_07 1920x1080")
176 std::vector<vpHomogeneousMatrix> cMo_vec;
177 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
178 CHECK(cMo_vec.size() == nbTags);
182 apriltag_detector.setAprilTagQuadDecimate(2);
183 BENCHMARK(
"Benchmark Apriltag detection: tag21_07 1920x1080 decimate=2")
185 std::vector<vpHomogeneousMatrix> cMo_vec;
186 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
187 CHECK(cMo_vec.size() == nbTags);
191 apriltag_detector.setAprilTagQuadDecimate(3);
192 BENCHMARK(
"Benchmark Apriltag detection: tag21_07 1920x1080 decimate=3")
194 std::vector<vpHomogeneousMatrix> cMo_vec;
195 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
196 CHECK(cMo_vec.size() == nbTags);
201 #if defined(VISP_HAVE_APRILTAG_BIG_FAMILY)
205 "AprilTag/benchmark/1920x1080/tag49_12_1920x1080.png");
211 BENCHMARK(
"Benchmark Apriltag detection: tag49_12 1920x1080")
213 std::vector<vpHomogeneousMatrix> cMo_vec;
214 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
215 CHECK(cMo_vec.size() == nbTags);
219 apriltag_detector.setAprilTagQuadDecimate(2);
220 BENCHMARK(
"Benchmark Apriltag detection: tag49_12 1920x1080 decimate=2")
222 std::vector<vpHomogeneousMatrix> cMo_vec;
223 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
224 CHECK(cMo_vec.size() == nbTags);
228 apriltag_detector.setAprilTagQuadDecimate(3);
229 BENCHMARK(
"Benchmark Apriltag detection: tag49_12 1920x1080 decimate=3")
231 std::vector<vpHomogeneousMatrix> cMo_vec;
232 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
233 CHECK(cMo_vec.size() == nbTags);
241 "AprilTag/benchmark/1920x1080/tag48_12_1920x1080.png");
247 BENCHMARK(
"Benchmark Apriltag detection: tag48_12 1920x1080")
249 std::vector<vpHomogeneousMatrix> cMo_vec;
250 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
251 CHECK(cMo_vec.size() == nbTags);
255 apriltag_detector.setAprilTagQuadDecimate(2);
256 BENCHMARK(
"Benchmark Apriltag detection: tag48_12 1920x1080 decimate=2")
258 std::vector<vpHomogeneousMatrix> cMo_vec;
259 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
260 CHECK(cMo_vec.size() == nbTags);
264 apriltag_detector.setAprilTagQuadDecimate(3);
265 BENCHMARK(
"Benchmark Apriltag detection: tag48_12 1920x1080 decimate=3")
267 std::vector<vpHomogeneousMatrix> cMo_vec;
268 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
269 CHECK(cMo_vec.size() == nbTags);
277 "AprilTag/benchmark/1920x1080/tag41_12_1920x1080.png");
283 BENCHMARK(
"Benchmark Apriltag detection: tag41_12 1920x1080")
285 std::vector<vpHomogeneousMatrix> cMo_vec;
286 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
287 CHECK(cMo_vec.size() == nbTags);
291 apriltag_detector.setAprilTagQuadDecimate(2);
292 BENCHMARK(
"Benchmark Apriltag detection: tag41_12 1920x1080 decimate=2")
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(3);
301 BENCHMARK(
"Benchmark Apriltag detection: tag41_12 1920x1080 decimate=3")
303 std::vector<vpHomogeneousMatrix> cMo_vec;
304 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
305 CHECK(cMo_vec.size() == nbTags);
313 "AprilTag/benchmark/1920x1080/tag52_13_1920x1080.png");
319 BENCHMARK(
"Benchmark Apriltag detection: tag52_13 1920x1080")
321 std::vector<vpHomogeneousMatrix> cMo_vec;
322 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
323 CHECK(cMo_vec.size() == nbTags);
327 apriltag_detector.setAprilTagQuadDecimate(2);
328 BENCHMARK(
"Benchmark Apriltag detection: tag52_13 1920x1080 decimate=2")
330 std::vector<vpHomogeneousMatrix> cMo_vec;
331 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
332 CHECK(cMo_vec.size() == nbTags);
336 apriltag_detector.setAprilTagQuadDecimate(3);
337 BENCHMARK(
"Benchmark Apriltag detection: tag52_13 1920x1080 decimate=3")
339 std::vector<vpHomogeneousMatrix> cMo_vec;
340 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
341 CHECK(cMo_vec.size() == nbTags);
348 TEST_CASE(
"Benchmark Apriltag detection 640x480",
"[benchmark]")
350 const double tagSize = 0.25;
352 const size_t nbTags = 5;
357 "AprilTag/benchmark/640x480/tag16_05_640x480.png");
363 BENCHMARK(
"Benchmark Apriltag detection: tag16_05 640x480")
365 std::vector<vpHomogeneousMatrix> cMo_vec;
366 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
367 CHECK(cMo_vec.size() == nbTags);
375 "AprilTag/benchmark/640x480/tag25_09_640x480.png");
381 BENCHMARK(
"Benchmark Apriltag detection: tag25_09 640x480")
383 std::vector<vpHomogeneousMatrix> cMo_vec;
384 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
385 CHECK(cMo_vec.size() == nbTags);
393 "AprilTag/benchmark/640x480/tag36_11_640x480.png");
399 BENCHMARK(
"Benchmark Apriltag detection: tag36_11 640x480")
401 std::vector<vpHomogeneousMatrix> cMo_vec;
402 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
403 CHECK(cMo_vec.size() == nbTags);
411 "AprilTag/benchmark/640x480/tag21_07_640x480.png");
417 BENCHMARK(
"Benchmark Apriltag detection: tag21_07 640x480")
419 std::vector<vpHomogeneousMatrix> cMo_vec;
420 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
421 CHECK(cMo_vec.size() == nbTags);
426 #if defined(VISP_HAVE_APRILTAG_BIG_FAMILY)
430 "AprilTag/benchmark/640x480/tag49_12_640x480.png");
436 BENCHMARK(
"Benchmark Apriltag detection: tag49_12 640x480")
438 std::vector<vpHomogeneousMatrix> cMo_vec;
439 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
440 CHECK(cMo_vec.size() == nbTags);
448 "AprilTag/benchmark/640x480/tag48_12_640x480.png");
454 BENCHMARK(
"Benchmark Apriltag detection: tag48_12 640x480")
456 std::vector<vpHomogeneousMatrix> cMo_vec;
457 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
458 CHECK(cMo_vec.size() == nbTags);
466 "AprilTag/benchmark/640x480/tag41_12_640x480.png");
472 BENCHMARK(
"Benchmark Apriltag detection: tag41_12 640x480")
474 std::vector<vpHomogeneousMatrix> cMo_vec;
475 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
476 CHECK(cMo_vec.size() == nbTags);
484 "AprilTag/benchmark/640x480/tag52_13_640x480.png");
490 BENCHMARK(
"Benchmark Apriltag detection: tag52_13 640x480")
492 std::vector<vpHomogeneousMatrix> cMo_vec;
493 apriltag_detector.detect(I, tagSize, cam, cMo_vec);
494 CHECK(cMo_vec.size() == nbTags);
501 int main(
int argc,
char *argv[])
503 Catch::Session session;
505 bool runBenchmark =
false;
506 auto cli = session.cli()
507 | Catch::Clara::Opt(runBenchmark)[
"--benchmark"](
"run benchmark?");
510 session.applyCommandLine(argc, argv);
513 int numFailed = session.run();
521 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)