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/vpMbEdgeKltTracker.h> 9 #include <visp3/mbt/vpMbEdgeTracker.h> 11 #include <visp3/io/vpVideoReader.h> 13 int main(
int argc,
char **argv)
15 #if defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100) 18 std::string opt_videoname =
"teabox.mpg";
19 std::string opt_modelname =
"teabox.cao";
22 for (
int i = 0; i < argc; i++) {
23 if (std::string(argv[i]) ==
"--video")
24 opt_videoname = std::string(argv[i + 1]);
25 else if (std::string(argv[i]) ==
"--model")
26 opt_modelname = std::string(argv[i + 1]);
27 else if (std::string(argv[i]) ==
"--tracker")
28 opt_tracker = atoi(argv[i + 1]);
29 else if (std::string(argv[i]) ==
"--help") {
30 std::cout <<
"\nUsage: " << argv[0]
31 <<
" [--video <video name>] [--model <model name>] " 32 "[--tracker <0=egde|1=keypoint|2=hybrid>] [--help]\n" 40 if (!parentname.empty())
41 objectname = parentname +
"/" + objectname;
43 std::cout <<
"Video name: " << opt_videoname << std::endl;
44 std::cout <<
"Tracker requested config files: " << objectname <<
".[init," 45 #ifdef VISP_HAVE_PUGIXML 48 <<
"cao or wrl]" << std::endl;
49 std::cout <<
"Tracker optional config files: " << objectname <<
".[ppm]" << std::endl;
64 #if defined(VISP_HAVE_X11) 66 #elif defined(VISP_HAVE_GDI) 71 display->init(I, 100, 100,
"Model-based tracker");
77 #ifdef VISP_HAVE_MODULE_KLT 78 else if (opt_tracker == 1)
84 std::cout <<
"klt and hybrid model-based tracker are not available " 85 "since visp_klt module is missing" 94 #ifdef VISP_HAVE_PUGIXML 104 if (opt_tracker == 0 || opt_tracker == 2) {
118 #ifdef VISP_HAVE_MODULE_KLT 119 if (opt_tracker == 1 || opt_tracker == 2) {
129 dynamic_cast<vpMbKltTracker *
>(tracker)->setKltOpencv(klt_settings);
175 tracker->
initClick(I, objectname +
".init",
true);
200 #if defined(VISP_HAVE_COIN3D) && (COIN_MAJOR_VERSION >= 2) 207 std::cout <<
"Catch a ViSP exception: " << e << std::endl;
209 #ifdef VISP_HAVE_OGRE 210 catch (Ogre::Exception &e) {
211 std::cout <<
"Catch an Ogre exception: " << e.getDescription() << std::endl;
217 std::cout <<
"Install OpenCV and rebuild ViSP to use this example." << std::endl;
virtual unsigned int getClipping() const
void setMaxFeatures(int maxCount)
Class that defines generic functionnalities for display.
virtual void track(const vpImage< unsigned char > &I)=0
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
void setHarrisFreeParameter(double harris_k)
virtual void loadModel(const std::string &modelFile, bool verbose=false, const vpHomogeneousMatrix &T=vpHomogeneousMatrix())
virtual void setAngleDisappear(const double &a)
Implementation of an homogeneous matrix and operations on such kind of matrices.
void setMaskNumber(const unsigned int &a)
virtual void loadConfigFile(const std::string &configFile)
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)
virtual void initClick(const vpImage< unsigned char > &I, const std::string &initFile, bool displayHelp=false, const vpHomogeneousMatrix &T=vpHomogeneousMatrix())
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
virtual void setOgreShowConfigDialog(bool showConfigDialog)
void setMinDistance(double minDistance)
error that can be emited by ViSP classes.
Make the complete tracking of an object by using its CAD model.
static void flush(const vpImage< unsigned char > &I)
virtual void display(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const vpColor &col, unsigned int thickness=1, bool displayFullModel=false)=0
void setMu1(const double &mu_1)
void setQuality(double qualityLevel)
void open(vpImage< vpRGBa > &I)
virtual void getPose(vpHomogeneousMatrix &cMo) const
virtual void setCameraParameters(const vpCameraParameters &cam)
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.
Main methods for a model-based tracker.
void acquire(vpImage< vpRGBa > &I)
void setWindowSize(int winSize)
virtual void setAngleAppear(const double &a)
Model based tracker using only KLT.
static double rad(double deg)
void initPersProjWithoutDistortion(double px, double py, double u0, double v0)
Hybrid tracker based on moving-edges and keypoints tracked using KLT tracker.
void setMu2(const double &mu_2)
virtual void setOgreVisibilityTest(const bool &v)
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)
virtual void setScanLineVisibilityTest(const bool &v)
virtual void setClipping(const unsigned int &flags)
void setRange(const unsigned int &r)
virtual void setFarClippingDistance(const double &dist)
void setBlockSize(int blockSize)
virtual void setDisplayFeatures(bool displayF)
virtual void getCameraParameters(vpCameraParameters &cam) const
virtual void setNearClippingDistance(const double &dist)