1 #include <visp3/core/vpIoTools.h>
3 #include <visp3/gui/vpDisplayGDI.h>
4 #include <visp3/gui/vpDisplayOpenCV.h>
5 #include <visp3/gui/vpDisplayX.h>
6 #include <visp3/io/vpImageIo.h>
8 #include <visp3/mbt/vpMbGenericTracker.h>
10 #include <visp3/io/vpVideoReader.h>
12 int main(
int argc,
char **argv)
14 #if defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)
16 std::string opt_videoname =
"model/teabox/teabox.mp4";
17 std::string opt_modelname =
"model/teabox/teabox.cao";
20 for (
int i = 0; i < argc; i++) {
21 if (std::string(argv[i]) ==
"--video")
22 opt_videoname = std::string(argv[i + 1]);
23 else if (std::string(argv[i]) ==
"--model")
24 opt_modelname = std::string(argv[i + 1]);
25 else if (std::string(argv[i]) ==
"--tracker")
26 opt_tracker = atoi(argv[i + 1]);
27 else if (std::string(argv[i]) ==
"--help" || std::string(argv[i]) ==
"-h") {
28 std::cout <<
"\nUsage: " << argv[0]
29 <<
" [--video <video name>] [--model <model name>]"
30 " [--tracker <0=egde|1=keypoint|2=hybrid>] [--help] [-h]\n"
38 if (!parentname.empty())
39 objectname = parentname +
"/" + objectname;
41 std::cout <<
"Video name: " << opt_videoname << std::endl;
42 std::cout <<
"Tracker requested config files: " << objectname <<
".[init, cao]" << std::endl;
43 std::cout <<
"Tracker optional config files: " << objectname <<
".[ppm]" << std::endl;
58 #if defined(VISP_HAVE_X11)
60 #elif defined(VISP_HAVE_GDI)
65 display->init(I, 100, 100,
"Model-based tracker");
71 #ifdef VISP_HAVE_MODULE_KLT
72 else if (opt_tracker == 1)
78 std::cout <<
"klt and hybrid model-based tracker are not available since visp_klt module is not available. "
79 "In CMakeGUI turn visp_klt module ON, configure and build ViSP again."
87 if (opt_tracker == 0 || opt_tracker == 2) {
99 #ifdef VISP_HAVE_MODULE_KLT
100 if (opt_tracker == 1 || opt_tracker == 2) {
127 tracker.
initClick(I, objectname +
".init",
true);
155 std::cout <<
"Catch a ViSP exception: " << e << std::endl;
160 std::cout <<
"Install OpenCV and rebuild ViSP to use this example." << std::endl;
Generic class defining intrinsic camera parameters.
void initPersProjWithoutDistortion(double px, double py, double u0, double v0)
static const vpColor none
Display for windows using GDI (available on any windows 32 platform).
The vpDisplayOpenCV allows to display image using the OpenCV library. Thus to enable this class OpenC...
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
Class that defines generic functionnalities for display.
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
static void display(const vpImage< unsigned char > &I)
static void flush(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))
static void displayText(const vpImage< unsigned char > &I, const vpImagePoint &ip, const std::string &s, const vpColor &color)
error that can be emited by ViSP classes.
Implementation of an homogeneous matrix and operations on such kind of matrices.
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)
Real-time 6D object pose tracking using its CAD model.
virtual void setCameraParameters(const vpCameraParameters &camera)
virtual void getPose(vpHomogeneousMatrix &cMo) const
virtual void setDisplayFeatures(bool displayF)
virtual void setKltMaskBorder(const unsigned int &e)
virtual void getCameraParameters(vpCameraParameters &camera) const
virtual void setMovingEdge(const vpMe &me)
virtual void setKltOpencv(const vpKltOpencv &t)
virtual void setTrackerType(int type)
virtual void initClick(const vpImage< unsigned char > &I1, const vpImage< unsigned char > &I2, const std::string &initFile1, const std::string &initFile2, bool displayHelp=false, const vpHomogeneousMatrix &T1=vpHomogeneousMatrix(), const vpHomogeneousMatrix &T2=vpHomogeneousMatrix())
virtual void loadModel(const std::string &modelFile, bool verbose=false, const vpHomogeneousMatrix &T=vpHomogeneousMatrix())
virtual void display(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const vpColor &col, unsigned int thickness=1, bool displayFullModel=false)
virtual void track(const vpImage< unsigned char > &I)
void setMu1(const double &mu_1)
void setSampleStep(const double &s)
void setRange(const unsigned int &r)
void setMaskSize(const unsigned int &a)
void setMu2(const double &mu_2)
void setMaskNumber(const unsigned int &a)
void setThreshold(const double &t)
Class that enables to manipulate easily a video file or a sequence of images. As it inherits from the...
void acquire(vpImage< vpRGBa > &I)
void open(vpImage< vpRGBa > &I)
void setFileName(const std::string &filename)