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(
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(
int maxCount);
149 void setMinDistance(
double minDistance);
150 void setMinEigThreshold(
double minEigThreshold);
151 void setPyramidLevels(
int pyrMaxLevel);
152 void setQuality(
double qualityLevel);
156 void setUseHarris(
int useHarrisDetector);
157 void setWindowSize(
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/vpDebug.h> 198 #include <visp3/core/vpDisplay.h> 199 #include <visp3/core/vpException.h> 200 #include <visp3/core/vpImage.h> 201 #include <visp3/core/vpTrackingException.h> 203 typedef int (*funccheck)(int, double, double);
204 typedef void (*funcinfo)(int, int, int, double, double);
205 typedef void (*funcevent)(int);
228 int globalcountFeatures;
236 double harris_free_parameter;
246 IplImage *prev_image;
248 IplImage *prev_pyramid;
252 int countPrevFeatures;
254 CvPoint2D32f *features;
255 CvPoint2D32f *prev_features;
258 long *prev_featuresid;
265 bool *lostDuringTrack;
271 funcevent OnInitialize;
272 funcinfo OnFeatureLost;
273 funcinfo OnNewFeature;
274 funcinfo OnMeasureFeature;
275 funccheck IsFeatureValid;
288 void addFeature(
const int &
id,
const float &x,
const float &y);
294 int getBlockSize()
const {
return block_size; }
295 void getFeature(
int index,
long &
id,
float &x,
float &y)
const;
297 CvPoint2D32f *getFeatures()
const {
return features; }
299 long *getFeaturesId()
const {
return featuresid; }
301 double getHarrisFreeParameter()
const {
return harris_free_parameter; }
303 bool *getListOfLostFeature()
const {
return lostDuringTrack; }
305 int getMaxFeatures()
const {
return maxFeatures; }
307 double getMinDistance()
const {
return min_distance; }
309 int getNbFeatures()
const {
return countFeatures; }
311 int getNbPrevFeatures()
const {
return countPrevFeatures; }
312 void getPrevFeature(
int index,
int &
id,
float &x,
float &y)
const;
314 CvPoint2D32f *getPrevFeatures()
const {
return prev_features; }
316 long *getPrevFeaturesId()
const {
return prev_featuresid; }
318 int getPyramidLevels()
const {
return pyramid_level; }
320 double getQuality()
const {
return quality; }
322 int getWindowSize()
const {
return win_size; }
325 void initTracking(
const IplImage *I,
const IplImage *mask = NULL);
326 void initTracking(
const IplImage *I, CvPoint2D32f *pts,
int size);
327 void initTracking(
const IplImage *I, CvPoint2D32f *pts,
long *fid,
int size);
330 void track(
const IplImage *I);
341 void setBlockSize(
int input)
354 void setHarrisFreeParameter(
double input)
357 harris_free_parameter = input;
359 void setInitialGuess(CvPoint2D32f **guess_pts);
360 void setInitialGuess(CvPoint2D32f **init_pts, CvPoint2D32f **guess_pts,
long *fid,
int size);
365 void setIsFeatureValid(funccheck input) { IsFeatureValid = input; }
368 void setMaxFeatures(
int input);
377 void setMinDistance(
double input)
380 min_distance = input;
386 void setOnInitialize(funcevent input) { OnInitialize = input; }
388 void setOnFeatureLost(funcinfo input) { OnFeatureLost = input; }
390 void setOnNewFeature(funcinfo input) { OnNewFeature = input; }
393 void setOnMeasureFeature(funcinfo input) { OnMeasureFeature = input; }
403 void setPyramidLevels(
int input)
406 pyramid_level = input;
408 void setQuality(
double input)
413 void setTrackerId(
int tid) { _tid = tid; }
422 void setUseHarris(
int input)
427 void setWindowSize(
int input)
433 void suppressFeature(
int index);
437 static void display(
const vpImage<unsigned char> &I,
const CvPoint2D32f *features_list,
const int &nbFeatures,
439 static void display(
const vpImage<vpRGBa> &I,
const CvPoint2D32f *features_list,
const int &nbFeatures,
442 static void display(
const vpImage<unsigned char> &I,
const CvPoint2D32f *features_list,
const long *featuresid_list,
444 static void display(
const vpImage<vpRGBa> &I,
const CvPoint2D32f *features_list,
const long *featuresid_list,
Class to define RGB 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.