#include <visp3/core/vpConfig.h>
#if defined(VISP_HAVE_CATCH2)
#include <catch_amalgamated.hpp>
#include <visp3/core/vpIoTools.h>
#include <visp3/detection/vpDetectorAprilTag.h>
#include <visp3/io/vpImageIo.h>
#ifdef ENABLE_VISP_NAMESPACE
#endif
TEST_CASE("Benchmark Apriltag detection 1920x1080", "[benchmark]")
{
const double tagSize = 0.25;
const size_t nbTags = 5;
SECTION("tag16_05")
{
"AprilTag/benchmark/1920x1080/tag16_05_1920x1080.png");
BENCHMARK("Benchmark Apriltag detection: tag16_05 1920x1080")
{
std::vector<vpHomogeneousMatrix> cMo_vec;
apriltag_detector.
detect(I, tagSize, cam, cMo_vec);
CHECK(cMo_vec.size() == nbTags);
return cMo_vec;
};
BENCHMARK("Benchmark Apriltag detection: tag16_05 1920x1080 decimate=2")
{
std::vector<vpHomogeneousMatrix> cMo_vec;
apriltag_detector.
detect(I, tagSize, cam, cMo_vec);
CHECK(cMo_vec.size() == nbTags);
return cMo_vec;
};
BENCHMARK("Benchmark Apriltag detection: tag16_05 1920x1080 decimate=3")
{
std::vector<vpHomogeneousMatrix> cMo_vec;
apriltag_detector.
detect(I, tagSize, cam, cMo_vec);
CHECK(cMo_vec.size() == nbTags);
return cMo_vec;
};
}
SECTION("tag25_09")
{
"AprilTag/benchmark/1920x1080/tag25_09_1920x1080.png");
BENCHMARK("Benchmark Apriltag detection: tag25_09 1920x1080")
{
std::vector<vpHomogeneousMatrix> cMo_vec;
apriltag_detector.
detect(I, tagSize, cam, cMo_vec);
CHECK(cMo_vec.size() == nbTags);
return cMo_vec;
};
BENCHMARK("Benchmark Apriltag detection: tag25_09 1920x1080 decimate=2")
{
std::vector<vpHomogeneousMatrix> cMo_vec;
apriltag_detector.
detect(I, tagSize, cam, cMo_vec);
CHECK(cMo_vec.size() == nbTags);
return cMo_vec;
};
BENCHMARK("Benchmark Apriltag detection: tag25_09 1920x1080 decimate=3")
{
std::vector<vpHomogeneousMatrix> cMo_vec;
apriltag_detector.
detect(I, tagSize, cam, cMo_vec);
CHECK(cMo_vec.size() == nbTags);
return cMo_vec;
};
}
SECTION("tag36_11")
{
"AprilTag/benchmark/1920x1080/tag36_11_1920x1080.png");
BENCHMARK("Benchmark Apriltag detection: tag36_11 1920x1080")
{
std::vector<vpHomogeneousMatrix> cMo_vec;
apriltag_detector.
detect(I, tagSize, cam, cMo_vec);
CHECK(cMo_vec.size() == nbTags);
return cMo_vec;
};
BENCHMARK("Benchmark Apriltag detection: tag36_11 1920x1080 decimate=2")
{
std::vector<vpHomogeneousMatrix> cMo_vec;
apriltag_detector.
detect(I, tagSize, cam, cMo_vec);
CHECK(cMo_vec.size() == nbTags);
return cMo_vec;
};
BENCHMARK("Benchmark Apriltag detection: tag36_11 1920x1080 decimate=3")
{
std::vector<vpHomogeneousMatrix> cMo_vec;
apriltag_detector.
detect(I, tagSize, cam, cMo_vec);
CHECK(cMo_vec.size() == nbTags);
return cMo_vec;
};
}
SECTION("tag21_07")
{
"AprilTag/benchmark/1920x1080/tag21_07_1920x1080.png");
BENCHMARK("Benchmark Apriltag detection: tag21_07 1920x1080")
{
std::vector<vpHomogeneousMatrix> cMo_vec;
apriltag_detector.
detect(I, tagSize, cam, cMo_vec);
CHECK(cMo_vec.size() == nbTags);
return cMo_vec;
};
BENCHMARK("Benchmark Apriltag detection: tag21_07 1920x1080 decimate=2")
{
std::vector<vpHomogeneousMatrix> cMo_vec;
apriltag_detector.
detect(I, tagSize, cam, cMo_vec);
CHECK(cMo_vec.size() == nbTags);
return cMo_vec;
};
BENCHMARK("Benchmark Apriltag detection: tag21_07 1920x1080 decimate=3")
{
std::vector<vpHomogeneousMatrix> cMo_vec;
apriltag_detector.
detect(I, tagSize, cam, cMo_vec);
CHECK(cMo_vec.size() == nbTags);
return cMo_vec;
};
}
#if defined(VISP_HAVE_APRILTAG_BIG_FAMILY)
SECTION("tag49_12")
{
"AprilTag/benchmark/1920x1080/tag49_12_1920x1080.png");
BENCHMARK("Benchmark Apriltag detection: tag49_12 1920x1080")
{
std::vector<vpHomogeneousMatrix> cMo_vec;
apriltag_detector.
detect(I, tagSize, cam, cMo_vec);
CHECK(cMo_vec.size() == nbTags);
return cMo_vec;
};
BENCHMARK("Benchmark Apriltag detection: tag49_12 1920x1080 decimate=2")
{
std::vector<vpHomogeneousMatrix> cMo_vec;
apriltag_detector.
detect(I, tagSize, cam, cMo_vec);
CHECK(cMo_vec.size() == nbTags);
return cMo_vec;
};
BENCHMARK("Benchmark Apriltag detection: tag49_12 1920x1080 decimate=3")
{
std::vector<vpHomogeneousMatrix> cMo_vec;
apriltag_detector.
detect(I, tagSize, cam, cMo_vec);
CHECK(cMo_vec.size() == nbTags);
return cMo_vec;
};
}
SECTION("tag48_12")
{
"AprilTag/benchmark/1920x1080/tag48_12_1920x1080.png");
BENCHMARK("Benchmark Apriltag detection: tag48_12 1920x1080")
{
std::vector<vpHomogeneousMatrix> cMo_vec;
apriltag_detector.
detect(I, tagSize, cam, cMo_vec);
CHECK(cMo_vec.size() == nbTags);
return cMo_vec;
};
BENCHMARK("Benchmark Apriltag detection: tag48_12 1920x1080 decimate=2")
{
std::vector<vpHomogeneousMatrix> cMo_vec;
apriltag_detector.
detect(I, tagSize, cam, cMo_vec);
CHECK(cMo_vec.size() == nbTags);
return cMo_vec;
};
BENCHMARK("Benchmark Apriltag detection: tag48_12 1920x1080 decimate=3")
{
std::vector<vpHomogeneousMatrix> cMo_vec;
apriltag_detector.
detect(I, tagSize, cam, cMo_vec);
CHECK(cMo_vec.size() == nbTags);
return cMo_vec;
};
}
SECTION("tag41_12")
{
"AprilTag/benchmark/1920x1080/tag41_12_1920x1080.png");
BENCHMARK("Benchmark Apriltag detection: tag41_12 1920x1080")
{
std::vector<vpHomogeneousMatrix> cMo_vec;
apriltag_detector.
detect(I, tagSize, cam, cMo_vec);
CHECK(cMo_vec.size() == nbTags);
return cMo_vec;
};
BENCHMARK("Benchmark Apriltag detection: tag41_12 1920x1080 decimate=2")
{
std::vector<vpHomogeneousMatrix> cMo_vec;
apriltag_detector.
detect(I, tagSize, cam, cMo_vec);
CHECK(cMo_vec.size() == nbTags);
return cMo_vec;
};
BENCHMARK("Benchmark Apriltag detection: tag41_12 1920x1080 decimate=3")
{
std::vector<vpHomogeneousMatrix> cMo_vec;
apriltag_detector.
detect(I, tagSize, cam, cMo_vec);
CHECK(cMo_vec.size() == nbTags);
return cMo_vec;
};
}
SECTION("tag52_13")
{
"AprilTag/benchmark/1920x1080/tag52_13_1920x1080.png");
BENCHMARK("Benchmark Apriltag detection: tag52_13 1920x1080")
{
std::vector<vpHomogeneousMatrix> cMo_vec;
apriltag_detector.
detect(I, tagSize, cam, cMo_vec);
CHECK(cMo_vec.size() == nbTags);
return cMo_vec;
};
BENCHMARK("Benchmark Apriltag detection: tag52_13 1920x1080 decimate=2")
{
std::vector<vpHomogeneousMatrix> cMo_vec;
apriltag_detector.
detect(I, tagSize, cam, cMo_vec);
CHECK(cMo_vec.size() == nbTags);
return cMo_vec;
};
BENCHMARK("Benchmark Apriltag detection: tag52_13 1920x1080 decimate=3")
{
std::vector<vpHomogeneousMatrix> cMo_vec;
apriltag_detector.
detect(I, tagSize, cam, cMo_vec);
CHECK(cMo_vec.size() == nbTags);
return cMo_vec;
};
}
#endif
}
TEST_CASE("Benchmark Apriltag detection 640x480", "[benchmark]")
{
const double tagSize = 0.25;
const size_t nbTags = 5;
SECTION("tag16_05")
{
"AprilTag/benchmark/640x480/tag16_05_640x480.png");
BENCHMARK("Benchmark Apriltag detection: tag16_05 640x480")
{
std::vector<vpHomogeneousMatrix> cMo_vec;
apriltag_detector.detect(I, tagSize, cam, cMo_vec);
CHECK(cMo_vec.size() == nbTags);
return cMo_vec;
};
}
SECTION("tag25_09")
{
"AprilTag/benchmark/640x480/tag25_09_640x480.png");
BENCHMARK("Benchmark Apriltag detection: tag25_09 640x480")
{
std::vector<vpHomogeneousMatrix> cMo_vec;
apriltag_detector.detect(I, tagSize, cam, cMo_vec);
CHECK(cMo_vec.size() == nbTags);
return cMo_vec;
};
}
SECTION("tag36_11")
{
"AprilTag/benchmark/640x480/tag36_11_640x480.png");
BENCHMARK("Benchmark Apriltag detection: tag36_11 640x480")
{
std::vector<vpHomogeneousMatrix> cMo_vec;
apriltag_detector.detect(I, tagSize, cam, cMo_vec);
CHECK(cMo_vec.size() == nbTags);
return cMo_vec;
};
}
SECTION("tag21_07")
{
"AprilTag/benchmark/640x480/tag21_07_640x480.png");
BENCHMARK("Benchmark Apriltag detection: tag21_07 640x480")
{
std::vector<vpHomogeneousMatrix> cMo_vec;
apriltag_detector.detect(I, tagSize, cam, cMo_vec);
CHECK(cMo_vec.size() == nbTags);
return cMo_vec;
};
}
#if defined(VISP_HAVE_APRILTAG_BIG_FAMILY)
SECTION("tag49_12")
{
"AprilTag/benchmark/640x480/tag49_12_640x480.png");
BENCHMARK("Benchmark Apriltag detection: tag49_12 640x480")
{
std::vector<vpHomogeneousMatrix> cMo_vec;
apriltag_detector.detect(I, tagSize, cam, cMo_vec);
CHECK(cMo_vec.size() == nbTags);
return cMo_vec;
};
}
SECTION("tag48_12")
{
"AprilTag/benchmark/640x480/tag48_12_640x480.png");
BENCHMARK("Benchmark Apriltag detection: tag48_12 640x480")
{
std::vector<vpHomogeneousMatrix> cMo_vec;
apriltag_detector.detect(I, tagSize, cam, cMo_vec);
CHECK(cMo_vec.size() == nbTags);
return cMo_vec;
};
}
SECTION("tag41_12")
{
"AprilTag/benchmark/640x480/tag41_12_640x480.png");
BENCHMARK("Benchmark Apriltag detection: tag41_12 640x480")
{
std::vector<vpHomogeneousMatrix> cMo_vec;
apriltag_detector.detect(I, tagSize, cam, cMo_vec);
CHECK(cMo_vec.size() == nbTags);
return cMo_vec;
};
}
SECTION("tag52_13")
{
"AprilTag/benchmark/640x480/tag52_13_640x480.png");
BENCHMARK("Benchmark Apriltag detection: tag52_13 640x480")
{
std::vector<vpHomogeneousMatrix> cMo_vec;
apriltag_detector.detect(I, tagSize, cam, cMo_vec);
CHECK(cMo_vec.size() == nbTags);
return cMo_vec;
};
}
#endif
}
int main(int argc, char *argv[])
{
Catch::Session session;
bool runBenchmark = false;
auto cli = session.cli()
| Catch::Clara::Opt(runBenchmark)["--benchmark"]("run benchmark?");
session.cli(cli);
session.applyCommandLine(argc, argv);
if (runBenchmark) {
int numFailed = session.run();
return numFailed;
}
return EXIT_SUCCESS;
}
#else
int main() { return EXIT_SUCCESS; }
#endif
Generic class defining intrinsic camera parameters.
void setAprilTagQuadDecimate(float quadDecimate)
bool detect(const vpImage< unsigned char > &I) VP_OVERRIDE
@ 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)