42 #ifndef _vpKltOpencv_h_
43 #define _vpKltOpencv_h_
45 #include <visp3/core/vpColor.h>
46 #include <visp3/core/vpConfig.h>
47 #include <visp3/core/vpImage.h>
49 #if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC) && defined(HAVE_OPENCV_VIDEO)
51 #include <opencv2/highgui/highgui.hpp>
52 #include <opencv2/imgproc/imgproc.hpp>
53 #include <opencv2/video/tracking.hpp>
93 void addFeature(
const float &x,
const float &y);
105 void addFeature(
const long &
id,
const float &x,
const float &y);
112 void addFeature(
const cv::Point2f &f);
140 static void display(
const vpImage<vpRGBa> &I,
const std::vector<cv::Point2f> &features,
153 unsigned int thickness = 1);
163 static void display(
const vpImage<vpRGBa> &I,
const std::vector<cv::Point2f> &features,
165 unsigned int thickness = 1);
180 void getFeature(
const int &index,
long &
id,
float &x,
float &y)
const;
182 std::vector<cv::Point2f>
getFeatures()
const {
return m_points[1]; }
224 void initTracking(
const cv::Mat &I,
const cv::Mat &mask = cv::Mat());
233 void initTracking(
const cv::Mat &I,
const std::vector<cv::Point2f> &pts);
243 void initTracking(
const cv::Mat &I,
const std::vector<cv::Point2f> &pts,
const std::vector<long> &ids);
255 void track(
const cv::Mat &I);
288 void setInitialGuess(
const std::vector<cv::Point2f> &guess_pts);
306 void setInitialGuess(
const std::vector<cv::Point2f> &init_pts,
const std::vector<cv::Point2f> &guess_pts,
307 const std::vector<long> &fid);
355 void setQuality(
double qualityLevel) { m_qualityLevel = qualityLevel; }
367 void setUseHarris(
int useHarrisDetector) { m_useHarrisDetector = useHarrisDetector; }
383 void suppressFeature(
const int &index);
388 std::vector<cv::Point2f> m_points[2];
Class to define RGB colors available for display functionalities.
static const vpColor green
Wrapper for the KLT (Kanade-Lucas-Tomasi) feature tracker implemented in OpenCV. Thus to enable this ...
std::vector< long > m_points_id
Keypoint id.
std::vector< cv::Point2f > getPrevFeatures() const
Get the list of previous features.
int m_useHarrisDetector
true to use Harris detector
int m_maxCount
Max number of keypoints.
double getQuality() const
int getMaxFeatures() const
Get the list of lost feature.
void setBlockSize(int blockSize)
int m_blockSize
Block size.
void setQuality(double qualityLevel)
int getNbPrevFeatures() const
Get the number of previous features.
void setTrackerId(int tid)
int getWindowSize() const
Get the window size used to refine the corner locations.
double m_minDistance
Mins distance between keypoints.
int getNbFeatures() const
Get the number of current features.
cv::TermCriteria m_termcrit
Term criteria.
std::vector< cv::Point2f > getFeatures() const
Get the list of current features.
double m_minEigThreshold
Min eigen threshold.
void setHarrisFreeParameter(double harris_k)
int m_pyrMaxLevel
Pyramid max level.
double getHarrisFreeParameter() const
Get the free parameter of the Harris detector.
double m_qualityLevel
Quality level.
bool m_initial_guess
true when initial guess is provided
cv::Mat m_gray
Gray image.
void setMaxFeatures(int maxCount)
void setMinEigThreshold(double minEigThreshold)
std::vector< long > getFeaturesId() const
Get the unique id of each feature.
double m_harris_k
Harris parameter.
double getMinDistance() const
int m_winSize
Window criteria.
long m_next_points_id
Id for the newt keypoint.
cv::Mat m_prevGray
Previous gray image.
void setMinDistance(double minDistance)
int getBlockSize() const
Get the size of the averaging block used to track the features.
int getPyramidLevels() const
Get the list of features id.
void setUseHarris(int useHarrisDetector)
void setWindowSize(int winSize)
void setPyramidLevels(int pyrMaxLevel)