#include <visp3/core/vpConfig.h>
#if defined(VISP_HAVE_CATCH2) && defined(VISP_HAVE_THREADS)
#include <catch_amalgamated.hpp>
#include <future>
#include <thread>
#include <visp3/core/vpIoTools.h>
#include <visp3/io/vpImageIo.h>
#include <visp3/mbt/vpMbGenericTracker.h>
#ifdef DEBUG_DISPLAY
#include <visp3/gui/vpDisplayX.h>
#endif
#ifdef ENABLE_VISP_NAMESPACE
#endif
namespace
{
{
#if VISP_HAVE_DATASET_VERSION >= 0x030600
std::string ext("png");
#else
std::string ext("pgm");
#endif
char buffer[FILENAME_MAX];
snprintf(buffer, FILENAME_MAX, ipath.c_str(), cpt);
std::string image_filename = buffer;
return false;
}
return true;
}
{
for (unsigned int i = 0; i < 3; i++) {
for (unsigned int j = 0; j < 4; j++) {
CHECK(cMo1[i][j] == Catch::Approx(cMo2[i][j]).epsilon(std::numeric_limits<double>::epsilon()));
}
}
}
{
#if defined(VISP_HAVE_PUGIXML)
const bool verbose = false;
#else
tracker.setKltOpencv(klt);
tracker.setKltMaskBorder(5);
#endif
const vpPoseVector initPose(0.02231950571, 0.1071368004, 0.5071128378, 2.100485509, 1.146812236, -0.4560126437);
read_data(0, I);
}
}
TEST_CASE("Check MBT determinism sequential", "[MBT_determinism]")
{
configureTracker(tracker1, cam);
read_data(0, I);
#ifdef DEBUG_DISPLAY
vpDisplayX d(I);
#endif
for (int cpt = 0; read_data(cpt, I); cpt++) {
#ifdef DEBUG_DISPLAY
#endif
}
std::cout << "First tracker, final cMo:\n" << cMo1 << std::endl;
configureTracker(tracker2, cam);
for (int cpt = 0; read_data(cpt, I); cpt++) {
#ifdef DEBUG_DISPLAY
#endif
}
std::cout << "Second tracker, final cMo:\n" << cMo2 << std::endl;
checkPoses(cMo1, cMo2);
}
TEST_CASE("Check MBT determinism parallel", "[MBT_determinism]")
{
std::future<vpHomogeneousMatrix> res_cMo1 = std::async(std::launch::async, []() {
configureTracker(tracker1, cam);
for (int cpt = 0; read_data(cpt, I); cpt++) {
}
return cMo1;
});
std::future<vpHomogeneousMatrix> res_cMo2 = std::async(std::launch::async, []() {
configureTracker(tracker2, cam);
for (int cpt = 0; read_data(cpt, I); cpt++) {
}
return cMo2;
});
std::cout << "Run both trackers in separate threads" << std::endl;
std::cout << "First tracker, final cMo:\n" << cMo1 << std::endl;
std::cout << "Second tracker, final cMo:\n" << cMo2 << std::endl;
checkPoses(cMo1, cMo2);
}
TEST_CASE("Check Stereo MBT determinism parallel", "[MBT_determinism]")
{
std::future<vpHomogeneousMatrix> res_cMo1 = std::async(std::launch::async, []() {
configureTracker(tracker1, cam);
for (int cpt = 0; read_data(cpt, I); cpt++) {
}
return cMo1;
});
std::future<vpHomogeneousMatrix> res_cMo2 = std::async(std::launch::async, []() {
configureTracker(tracker2, cam);
for (int cpt = 0; read_data(cpt, I); cpt++) {
}
return cMo2;
});
std::cout << "Run both stereo trackers in separate threads" << std::endl;
std::cout << "First tracker, final cMo:\n" << cMo1 << std::endl;
std::cout << "Second tracker, final cMo:\n" << cMo2 << std::endl;
checkPoses(cMo1, cMo2);
}
int main(int argc, char *argv[])
{
Catch::Session session;
session.applyCommandLine(argc, argv);
int numFailed = session.run();
return numFailed;
}
#else
#include <iostream>
int main() { return EXIT_SUCCESS; }
#endif
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.