38 #include <visp3/core/vpConfig.h>
40 #if defined(VISP_HAVE_CATCH2) && defined(VISP_HAVE_THREADS)
42 #include <catch_amalgamated.hpp>
46 #include <visp3/core/vpIoTools.h>
47 #include <visp3/io/vpImageIo.h>
48 #include <visp3/mbt/vpMbGenericTracker.h>
52 #include <visp3/gui/vpDisplayX.h>
55 #ifdef ENABLE_VISP_NAMESPACE
63 #if VISP_HAVE_DATASET_VERSION >= 0x030600
64 std::string ext(
"png");
66 std::string ext(
"pgm");
71 char buffer[FILENAME_MAX];
72 snprintf(buffer, FILENAME_MAX, ipath.c_str(), cpt);
73 std::string image_filename = buffer;
85 for (
unsigned int i = 0; i < 3; i++) {
86 for (
unsigned int j = 0; j < 4; j++) {
87 CHECK(cMo1[i][j] == Catch::Approx(cMo2[i][j]).epsilon(std::numeric_limits<double>::epsilon()));
97 #if defined(VISP_HAVE_PUGIXML)
98 const bool verbose =
false;
126 tracker.setKltOpencv(klt);
127 tracker.setKltMaskBorder(5);
143 const vpPoseVector initPose(0.02231950571, 0.1071368004, 0.5071128378, 2.100485509, 1.146812236, -0.4560126437);
150 TEST_CASE(
"Check MBT determinism sequential",
"[MBT_determinism]")
155 configureTracker(tracker1, cam);
164 for (
int cpt = 0; read_data(cpt, I); cpt++) {
175 std::cout <<
"First tracker, final cMo:\n" << cMo1 << std::endl;
179 configureTracker(tracker2, cam);
181 for (
int cpt = 0; read_data(cpt, I); cpt++) {
192 std::cout <<
"Second tracker, final cMo:\n" << cMo2 << std::endl;
195 checkPoses(cMo1, cMo2);
198 TEST_CASE(
"Check MBT determinism parallel",
"[MBT_determinism]")
201 std::future<vpHomogeneousMatrix> res_cMo1 = std::async(std::launch::async, []() {
204 configureTracker(tracker1, cam);
208 for (
int cpt = 0; read_data(cpt, I); cpt++) {
216 std::future<vpHomogeneousMatrix> res_cMo2 = std::async(std::launch::async, []() {
219 configureTracker(tracker2, cam);
223 for (
int cpt = 0; read_data(cpt, I); cpt++) {
232 std::cout <<
"Run both trackers in separate threads" << std::endl;
233 std::cout <<
"First tracker, final cMo:\n" << cMo1 << std::endl;
234 std::cout <<
"Second tracker, final cMo:\n" << cMo2 << std::endl;
237 checkPoses(cMo1, cMo2);
240 TEST_CASE(
"Check Stereo MBT determinism parallel",
"[MBT_determinism]")
243 std::future<vpHomogeneousMatrix> res_cMo1 = std::async(std::launch::async, []() {
246 configureTracker(tracker1, cam);
250 for (
int cpt = 0; read_data(cpt, I); cpt++) {
251 tracker1.
track(I, I);
258 std::future<vpHomogeneousMatrix> res_cMo2 = std::async(std::launch::async, []() {
261 configureTracker(tracker2, cam);
265 for (
int cpt = 0; read_data(cpt, I); cpt++) {
266 tracker2.
track(I, I);
274 std::cout <<
"Run both stereo trackers in separate threads" << std::endl;
275 std::cout <<
"First tracker, final cMo:\n" << cMo1 << std::endl;
276 std::cout <<
"Second tracker, final cMo:\n" << cMo2 << std::endl;
279 checkPoses(cMo1, cMo2);
282 int main(
int argc,
char *argv[])
284 Catch::Session session;
285 session.applyCommandLine(argc, argv);
286 int numFailed = session.run();
293 int main() {
return EXIT_SUCCESS; }
Generic class defining intrinsic camera parameters.
void initPersProjWithoutDistortion(double px, double py, double u0, double v0)
static const vpColor none
static void display(const vpImage< unsigned char > &I)
static void displayFrame(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, double size, const vpColor &color=vpColor::none, unsigned int thickness=1, const vpImagePoint &offset=vpImagePoint(0, 0), const std::string &frameName="", const vpColor &textColor=vpColor::black, const vpImagePoint &textOffset=vpImagePoint(15, 15))
static void flush(const vpImage< unsigned char > &I)
Implementation of an homogeneous matrix and operations on such kind of matrices.
static void read(vpImage< unsigned char > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND)
Wrapper for the KLT (Kanade-Lucas-Tomasi) feature tracker implemented in OpenCV. Thus to enable this ...
void setBlockSize(int blockSize)
void setQuality(double qualityLevel)
void setHarrisFreeParameter(double harris_k)
void setMaxFeatures(int maxCount)
void setMinDistance(double minDistance)
void setWindowSize(int winSize)
void setPyramidLevels(int pyrMaxLevel)
static double rad(double deg)
Real-time 6D object pose tracking using its CAD model.
virtual void setCameraParameters(const vpCameraParameters &camera) VP_OVERRIDE
virtual void setDisplayFeatures(bool displayF) VP_OVERRIDE
virtual void getCameraParameters(vpCameraParameters &camera) const VP_OVERRIDE
virtual void initFromPose(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo) VP_OVERRIDE
virtual void getPose(vpHomogeneousMatrix &cMo) const VP_OVERRIDE
virtual void setMovingEdge(const vpMe &me)
virtual void setAngleDisappear(const double &a) VP_OVERRIDE
virtual void track(const vpImage< unsigned char > &I) VP_OVERRIDE
virtual void loadModel(const std::string &modelFile, bool verbose=false, const vpHomogeneousMatrix &T=vpHomogeneousMatrix()) VP_OVERRIDE
virtual void getClipping(unsigned int &clippingFlag1, unsigned int &clippingFlag2) const
virtual void setClipping(const unsigned int &flags) VP_OVERRIDE
virtual void setNearClippingDistance(const double &dist) VP_OVERRIDE
virtual void display(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const vpColor &col, unsigned int thickness=1, bool displayFullModel=false) VP_OVERRIDE
virtual void loadConfigFile(const std::string &configFile, bool verbose=true) VP_OVERRIDE
virtual void setAngleAppear(const double &a) VP_OVERRIDE
virtual void setFarClippingDistance(const double &dist) VP_OVERRIDE
void setMu1(const double &mu_1)
void setRange(const unsigned int &range)
void setLikelihoodThresholdType(const vpLikelihoodThresholdType likelihood_threshold_type)
void setMaskNumber(const unsigned int &mask_number)
void setThreshold(const double &threshold)
void setSampleStep(const double &sample_step)
void setMaskSize(const unsigned int &mask_size)
void setMu2(const double &mu_2)
Implementation of a pose vector and operations on poses.