3 #include <visp3/core/vpConfig.h> 4 #include <visp3/core/vpIoTools.h> 5 #include <visp3/gui/vpDisplayGDI.h> 6 #include <visp3/gui/vpDisplayOpenCV.h> 7 #include <visp3/gui/vpDisplayX.h> 8 #include <visp3/io/vpImageIo.h> 10 #include <visp3/mbt/vpMbGenericTracker.h> 12 #include <visp3/io/vpVideoReader.h> 14 int main(
int argc,
char **argv)
16 #if defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020300) 18 std::string opt_videoname =
"teabox.mpg";
21 for (
int i = 0; i < argc; i++) {
22 if (std::string(argv[i]) ==
"--name" && i + 1 < argc)
23 opt_videoname = std::string(argv[i + 1]);
24 else if (std::string(argv[i]) ==
"--tracker" && i + 1 < argc)
25 opt_tracker = atoi(argv[i + 1]);
26 else if (std::string(argv[i]) ==
"--help") {
27 std::cout <<
"\nUsage: " << argv[0]
28 <<
" [--name <video name>] [--tracker " 29 "<1=egde|2=keypoint|3=hybrid>] [--help]\n" 35 if (opt_tracker < 1 || opt_tracker > 3) {
36 std::cerr <<
"Wrong tracker type. Correct values are: " 37 "1=egde|2=keypoint|3=hybrid." 45 if (!parentname.empty()) {
46 objectname = parentname +
"/" + objectname;
49 std::cout <<
"Video name: " << opt_videoname << std::endl;
50 std::cout <<
"Tracker requested config files: " << objectname <<
".[init, cao]" << std::endl;
51 std::cout <<
"Tracker optional config files: " << objectname <<
".[ppm]" << std::endl;
61 #if defined(VISP_HAVE_X11) 63 #elif defined(VISP_HAVE_GDI) 68 display.
init(I, 100, 100,
"Model-based tracker");
74 #if !defined(VISP_HAVE_MODULE_KLT) 75 if (opt_tracker >= 2) {
76 std::cout <<
"KLT and hybrid model-based tracker are not available " 77 "since visp_klt module is missing" 84 #ifdef VISP_HAVE_PUGIXML 85 tracker.loadConfigFile(objectname +
".xml");
89 if (opt_tracker == 1 || opt_tracker == 3) {
98 tracker.setMovingEdge(me);
101 #ifdef VISP_HAVE_MODULE_KLT 102 if (opt_tracker == 2 || opt_tracker == 3) {
104 tracker.setKltMaskBorder(5);
112 tracker.setKltOpencv(klt_settings);
120 tracker.setCameraParameters(cam);
127 tracker.loadModel(objectname +
".cao");
130 tracker.setDisplayFeatures(
true);
133 tracker.initClick(I, objectname +
".init",
true);
144 tracker.getPose(cMo);
148 tracker.getCameraParameters(cam);
161 std::cerr <<
"Catch a ViSP exception: " << e.
what() << std::endl;
168 std::cout <<
"Install OpenCV and rebuild ViSP to use this example." << std::endl;
void setMaxFeatures(int maxCount)
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
void setHarrisFreeParameter(double harris_k)
Implementation of an homogeneous matrix and operations on such kind of matrices.
void setMaskNumber(const unsigned int &a)
Display for windows using GDI (available on any windows 32 platform).
void setSampleStep(const double &s)
static void displayText(const vpImage< unsigned char > &I, const vpImagePoint &ip, const std::string &s, const vpColor &color)
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
Class that enables to manipulate easily a video file or a sequence of images. As it inherits from the...
static const vpColor none
void setMinDistance(double minDistance)
error that can be emited by ViSP classes.
void init(vpImage< unsigned char > &I, int winx=-1, int winy=-1, const std::string &title="")
Real-time 6D object pose tracking using its CAD model.
static void flush(const vpImage< unsigned char > &I)
void setMu1(const double &mu_1)
void setQuality(double qualityLevel)
void open(vpImage< vpRGBa > &I)
void setMaskSize(const unsigned int &a)
void setPyramidLevels(int pyrMaxLevel)
static void display(const vpImage< unsigned char > &I)
The vpDisplayOpenCV allows to display image using the OpenCV library. Thus to enable this class OpenC...
Generic class defining intrinsic camera parameters.
void acquire(vpImage< vpRGBa > &I)
void setWindowSize(int winSize)
const char * what() const
void initPersProjWithoutDistortion(double px, double py, double u0, double v0)
void setMu2(const double &mu_2)
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))
Wrapper for the KLT (Kanade-Lucas-Tomasi) feature tracker implemented in OpenCV. Thus to enable this ...
void setThreshold(const double &t)
void setFileName(const std::string &filename)
void setRange(const unsigned int &r)
void setBlockSize(int blockSize)