1 #include <visp/vpConfig.h>
3 #include <visp/vpDisplayX.h>
4 #include <visp/vpDisplayGDI.h>
5 #include <visp/vpDisplayOpenCV.h>
6 #include <visp/vpMbEdgeTracker.h>
7 #include <visp/vpVideoReader.h>
8 #include <visp/vpKeyPoint.h>
11 int main(
int argc,
char ** argv) {
12 #if defined(VISP_HAVE_OPENCV) && ((VISP_HAVE_OPENCV_VERSION >= 0x020100) || defined(VISP_HAVE_FFMPEG))
15 std::string videoname =
"teabox.mpg";
17 for (
int i=0; i<argc; i++) {
18 if (std::string(argv[i]) ==
"--name")
19 videoname = std::string(argv[i+1]);
20 else if (std::string(argv[i]) ==
"--help") {
21 std::cout <<
"\nUsage: " << argv[0] <<
" [--name <video name>] [--help]\n" << std::endl;
28 if(! parentname.empty())
29 objectname = parentname +
"/" + objectname;
31 std::cout <<
"Video name: " << videoname << std::endl;
32 std::cout <<
"Tracker requested config files: " << objectname
37 <<
"cao or wrl]" << std::endl;
38 std::cout <<
"Tracker optional config files: " << objectname <<
".[ppm]" << std::endl;
48 #if defined(VISP_HAVE_X11)
50 #elif defined(VISP_HAVE_GDI)
52 #elif defined(VISP_HAVE_OPENCV)
55 std::cout <<
"No image viewer is available..." << std::endl;
59 display.
init(I, 100, 100,
"Model-based edge tracker");
96 tracker.
initClick(I, objectname +
".init",
true);
101 std::string detectorName =
"FAST";
102 std::string extractorName =
"ORB";
103 std::string matcherName =
"BruteForce-Hamming";
104 std::string configurationFile =
"detection-config.xml";
106 #if (defined(VISP_HAVE_OPENCV_NONFREE) || defined(VISP_HAVE_OPENCV_XFEATURES2D))
107 detectorName =
"SIFT";
108 extractorName =
"SIFT";
109 matcherName =
"BruteForce";
110 configurationFile =
"detection-config-SIFT.xml";
119 #ifdef VISP_HAVE_XML2
133 std::vector<cv::KeyPoint> trainKeyPoints;
135 keypoint_learning.
detect(I, trainKeyPoints, elapsedTime);
139 std::vector<vpPolygon> polygons;
140 std::vector<std::vector<vpPoint> > roisPt;
141 std::pair<std::vector<vpPolygon>, std::vector<std::vector<vpPoint> > > pair = tracker.
getPolygonFaces(
false);
142 polygons = pair.first;
143 roisPt = pair.second;
145 std::vector<cv::Point3f> points3f;
160 for(std::vector<cv::KeyPoint>::const_iterator it = trainKeyPoints.begin(); it != trainKeyPoints.end(); ++it) {
172 #ifdef VISP_HAVE_XML2
194 bool click_done =
false;
203 if(keypoint_detection.
matchPoint(I, cam, cMo, error, elapsedTime)) {
224 #ifdef VISP_HAVE_XML2
227 #if defined(VISP_HAVE_COIN) && (COIN_MAJOR_VERSION == 3)
232 std::cout <<
"Catch an exception: " << e << std::endl;
237 std::cout <<
"Install OpenCV or ffmpeg and rebuild ViSP to use this example." << std::endl;
void init(vpImage< unsigned char > &I, int winx=-1, int winy=-1, const char *title=NULL)
void setRansacIteration(const int nbIter)
void setMovingEdge(const vpMe &me)
void setUseRansacVVS(const bool ransacVVS)
virtual unsigned int getClipping() const
virtual void setAngleDisappear(const double &a)
The class provides a data structure for the homogeneous matrices as well as a set of operations on th...
void track(const vpImage< unsigned char > &I)
void detect(const vpImage< unsigned char > &I, std::vector< cv::KeyPoint > &keyPoints, double &elapsedTime, const vpRect &rectangle=vpRect())
void setMaskNumber(const unsigned int &a)
void setRansacThreshold(const double threshold)
void setExtractor(const std::string &extractorName)
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)
void setNbTotalSample(const int &nb)
Define the X11 console to display images.
Class that enables to manipulate easily a video file or a sequence of images. As it inherits from the...
static const vpColor none
error that can be emited by ViSP classes.
Contains predetermined masks for sites and holds moving edges tracking parameters.
Make the complete tracking of an object by using its CAD model.
virtual void setPose(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cdMo)
static void compute3DForPointsInPolygons(const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, std::vector< cv::KeyPoint > &candidate, std::vector< vpPolygon > &polygons, std::vector< std::vector< vpPoint > > &roisPt, std::vector< cv::Point3f > &points, cv::Mat *descriptors=NULL)
virtual void setCameraParameters(const vpCameraParameters &camera)
void loadConfigFile(const std::string &configFile)
static void flush(const vpImage< unsigned char > &I)
void setMu1(const double &mu_1)
void initPersProjWithoutDistortion(const double px, const double py, const double u0, const double v0)
virtual void setNearClippingDistance(const double &dist)
virtual void setOgreVisibilityTest(const bool &v)
void setMatcher(const std::string &matcherName)
void open(vpImage< vpRGBa > &I)
void setMaskSize(const unsigned int &a)
void getPose(vpHomogeneousMatrix &cMo_) const
static void display(const vpImage< unsigned char > &I)
The vpDisplayOpenCV allows to display image using the opencv library.
virtual void displayCross(const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1)=0
virtual void getCameraParameters(vpCameraParameters &camera) const
Generic class defining intrinsic camera parameters.
void acquire(vpImage< vpRGBa > &I)
unsigned int buildReference(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)
virtual void setFarClippingDistance(const double &dist)
void setFileName(const char *filename)
virtual void setAngleAppear(const double &a)
virtual void initClick(const vpImage< unsigned char > &I, const std::string &initFile, const bool displayHelp=false)
static double rad(double deg)
unsigned int matchPoint(const vpImage< unsigned char > &I)
void setRansacConsensusPercentage(const double percentage)
void setMu2(const double &mu_2)
void loadLearningData(const std::string &filename, const bool binaryMode=false, const bool append=false)
virtual void loadModel(const char *modelFile, const bool verbose=false)
Class that allows keypoints detection (and descriptors extraction) and matching thanks to OpenCV libr...
void saveLearningData(const std::string &filename, const bool binaryMode=false, const bool saveTrainingImages=true)
void setThreshold(const double &t)
void display(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const vpColor &col, const unsigned int thickness=1, const bool displayFullModel=false)
void setDetector(const std::string &detectorName)
void setUseRansacConsensusPercentage(const bool usePercentage)
virtual bool getClick(bool blocking=true)=0
void loadConfigFile(const std::string &configFile)
void setDisplayFeatures(const bool displayF)
void setFilterMatchingType(const vpFilterMatchingType &filterType)
void setRange(const unsigned int &r)
virtual void setClipping(const unsigned int &flags)
virtual std::pair< std::vector< vpPolygon >, std::vector< std::vector< vpPoint > > > getPolygonFaces(const bool orderPolygons=true, const bool useVisibility=true)
void setMatchingRatioThreshold(const double ratio)