51 #include <visp3/core/vpColor.h> 52 #include <visp3/core/vpConfig.h> 53 #include <visp3/core/vpImage.h> 55 #if (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020408)) 57 #include <opencv2/highgui/highgui.hpp> 58 #include <opencv2/imgproc/imgproc.hpp> 59 #include <opencv2/video/tracking.hpp> 85 void addFeature(
const float &x,
const float &y);
86 void addFeature(
const long &
id,
const float &x,
const float &y);
87 void addFeature(
const cv::Point2f &f);
92 static void display(
const vpImage<vpRGBa> &I,
const std::vector<cv::Point2f> &features,
96 unsigned int thickness = 1);
97 static void display(
const vpImage<vpRGBa> &I,
const std::vector<cv::Point2f> &features,
99 unsigned int thickness = 1);
103 void getFeature(
const int &index,
long &
id,
float &x,
float &y)
const;
105 std::vector<cv::Point2f>
getFeatures()
const {
return m_points[1]; }
137 void initTracking(
const cv::Mat &I,
const cv::Mat &mask = cv::Mat());
138 void initTracking(
const cv::Mat &I,
const std::vector<cv::Point2f> &pts);
139 void initTracking(
const cv::Mat &I,
const std::vector<cv::Point2f> &pts,
const std::vector<long> &ids);
142 void track(
const cv::Mat &I);
143 void setBlockSize(
const int blockSize);
144 void setHarrisFreeParameter(
double harris_k);
145 void setInitialGuess(
const std::vector<cv::Point2f> &guess_pts);
146 void setInitialGuess(
const std::vector<cv::Point2f> &init_pts,
const std::vector<cv::Point2f> &guess_pts,
147 const std::vector<long> &fid);
148 void setMaxFeatures(
const int maxCount);
149 void setMinDistance(
double minDistance);
150 void setMinEigThreshold(
double minEigThreshold);
151 void setPyramidLevels(
const int pyrMaxLevel);
152 void setQuality(
double qualityLevel);
156 void setUseHarris(
const int useHarrisDetector);
157 void setWindowSize(
const int winSize);
158 void suppressFeature(
const int &index);
162 std::vector<cv::Point2f> m_points[2];
178 #elif defined(VISP_HAVE_OPENCV) 180 #pragma package < opencv > 183 #if (VISP_HAVE_OPENCV_VERSION >= 0x020101) // Require opencv >= 2.1.1 184 #include <opencv2/highgui/highgui.hpp> 185 #include <opencv2/imgproc/imgproc.hpp> 186 #include <opencv2/legacy/legacy.hpp> 187 #include <opencv2/video/tracking.hpp> 197 #include <visp3/core/vpConfig.h> 198 #include <visp3/core/vpDebug.h> 199 #include <visp3/core/vpDisplay.h> 200 #include <visp3/core/vpException.h> 201 #include <visp3/core/vpImage.h> 202 #include <visp3/core/vpTrackingException.h> 204 typedef int (*funccheck)(int, double, double);
205 typedef void (*funcinfo)(int, int, int, double, double);
206 typedef void (*funcevent)(int);
229 int globalcountFeatures;
237 double harris_free_parameter;
247 IplImage *prev_image;
249 IplImage *prev_pyramid;
253 int countPrevFeatures;
255 CvPoint2D32f *features;
256 CvPoint2D32f *prev_features;
259 long *prev_featuresid;
266 bool *lostDuringTrack;
272 funcevent OnInitialize;
273 funcinfo OnFeatureLost;
274 funcinfo OnNewFeature;
275 funcinfo OnMeasureFeature;
276 funccheck IsFeatureValid;
289 void addFeature(
const int &
id,
const float &x,
const float &y);
295 int getBlockSize()
const {
return block_size; }
296 void getFeature(
int index,
long &
id,
float &x,
float &y)
const;
298 CvPoint2D32f *getFeatures()
const {
return features; }
300 long *getFeaturesId()
const {
return featuresid; }
302 double getHarrisFreeParameter()
const {
return harris_free_parameter; }
304 bool *getListOfLostFeature()
const {
return lostDuringTrack; }
306 int getMaxFeatures()
const {
return maxFeatures; }
308 double getMinDistance()
const {
return min_distance; }
310 int getNbFeatures()
const {
return countFeatures; }
312 int getNbPrevFeatures()
const {
return countPrevFeatures; }
313 void getPrevFeature(
int index,
int &
id,
float &x,
float &y)
const;
315 CvPoint2D32f *getPrevFeatures()
const {
return prev_features; }
317 long *getPrevFeaturesId()
const {
return prev_featuresid; }
319 int getPyramidLevels()
const {
return pyramid_level; }
321 double getQuality()
const {
return quality; }
323 int getWindowSize()
const {
return win_size; }
326 void initTracking(
const IplImage *I,
const IplImage *mask = NULL);
327 void initTracking(
const IplImage *I, CvPoint2D32f *pts,
int size);
328 void initTracking(
const IplImage *I, CvPoint2D32f *pts,
long *fid,
int size);
331 void track(
const IplImage *I);
342 void setBlockSize(
const int input)
355 void setHarrisFreeParameter(
double input)
358 harris_free_parameter = input;
360 void setInitialGuess(CvPoint2D32f **guess_pts);
361 void setInitialGuess(CvPoint2D32f **init_pts, CvPoint2D32f **guess_pts,
long *fid,
int size);
366 void setIsFeatureValid(funccheck input) { IsFeatureValid = input; }
369 void setMaxFeatures(
const int input);
378 void setMinDistance(
double input)
381 min_distance = input;
387 void setOnInitialize(funcevent input) { OnInitialize = input; }
389 void setOnFeatureLost(funcinfo input) { OnFeatureLost = input; }
391 void setOnNewFeature(funcinfo input) { OnNewFeature = input; }
394 void setOnMeasureFeature(funcinfo input) { OnMeasureFeature = input; }
404 void setPyramidLevels(
const int input)
407 pyramid_level = input;
409 void setQuality(
double input)
414 void setTrackerId(
int tid) { _tid = tid; }
423 void setUseHarris(
const int input)
428 void setWindowSize(
const int input)
434 void suppressFeature(
int index);
438 static void display(
const vpImage<unsigned char> &I,
const CvPoint2D32f *features_list,
const int &nbFeatures,
440 static void display(
const vpImage<vpRGBa> &I,
const CvPoint2D32f *features_list,
const int &nbFeatures,
443 static void display(
const vpImage<unsigned char> &I,
const CvPoint2D32f *features_list,
const long *featuresid_list,
445 static void display(
const vpImage<vpRGBa> &I,
const CvPoint2D32f *features_list,
const long *featuresid_list,
Class to define colors available for display functionnalities.
std::vector< cv::Point2f > getFeatures() const
Get the list of current features.
int getNbFeatures() const
Get the number of current features.
cv::TermCriteria m_termcrit
static const vpColor green
int getWindowSize() const
Get the window size used to refine the corner locations.
std::vector< long > m_points_id
Keypoint id.
int getMaxFeatures() const
Get the list of lost feature.
void setTrackerId(int tid)
int getPyramidLevels() const
Get the list of features id.
double getMinDistance() const
double getHarrisFreeParameter() const
Get the free parameter of the Harris detector.
int getNbPrevFeatures() const
Get the number of previous features.
Wrapper for the KLT (Kanade-Lucas-Tomasi) feature tracker implemented in OpenCV. Thus to enable this ...
std::vector< long > getFeaturesId() const
Get the unique id of each feature.
double getQuality() const
int getBlockSize() const
Get the size of the averaging block used to track the features.
std::vector< cv::Point2f > getPrevFeatures() const
Get the list of previous features.