42#ifndef VP_KLT_OPENCV_H
43#define VP_KLT_OPENCV_H
45#include <visp3/core/vpConfig.h>
47#if defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC) && defined(HAVE_OPENCV_VIDEO)
49#include <visp3/core/vpColor.h>
50#include <visp3/core/vpImage.h>
52#include <opencv2/highgui/highgui.hpp>
53#include <opencv2/imgproc/imgproc.hpp>
54#include <opencv2/video/tracking.hpp>
56#if defined(VISP_HAVE_NLOHMANN_JSON)
57#include VISP_NLOHMANN_JSON(json.hpp)
105 void addFeature(
const float &x,
const float &y);
118 void addFeature(
const long &
id,
const float &x,
const float &y);
166 unsigned int thickness = 1);
178 unsigned int thickness = 1);
193 void getFeature(
const int &index,
long &
id,
float &x,
float &y)
const;
237 void initTracking(
const cv::Mat &I,
const cv::Mat &mask = cv::Mat());
246 void initTracking(
const cv::Mat &I,
const std::vector<cv::Point2f> &pts);
256 void initTracking(
const cv::Mat &I,
const std::vector<cv::Point2f> &pts,
const std::vector<long> &ids);
268 void track(
const cv::Mat &I);
301 void setInitialGuess(
const std::vector<cv::Point2f> &guess_pts);
319 void setInitialGuess(
const std::vector<cv::Point2f> &init_pts,
const std::vector<cv::Point2f> &guess_pts,
320 const std::vector<long> &fid);
396 void suppressFeature(
const int &index);
398#ifdef VISP_HAVE_NLOHMANN_JSON
399 friend void to_json(nlohmann::json &j,
const vpKltOpencv &array);
400 friend void from_json(
const nlohmann::json &j,
vpKltOpencv &array);
422#ifdef VISP_HAVE_NLOHMANN_JSON
Class to define RGB colors available for display functionalities.
static const vpColor green
Definition of the vpImage class member functions.
Wrapper for the KLT (Kanade-Lucas-Tomasi) feature tracker implemented in OpenCV. Thus to enable this ...
std::vector< long > m_points_id
Keypoint id.
void display(const vpImage< unsigned char > &I, const vpColor &color=vpColor::red, unsigned int thickness=1) const
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)
friend void to_json(nlohmann::json &j, const vpKltOpencv &array)
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 > getPrevFeatures() const
Get the list of previous features.
double m_minEigThreshold
Min eigen threshold.
void setHarrisFreeParameter(double harris_k)
int m_pyrMaxLevel
Pyramid max level.
std::vector< cv::Point2f > m_points[2]
Previous [0] and current [1] keypoint location.
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.
void addFeature(const float &x, const float &y)
double m_harris_k
Harris parameter.
friend void from_json(const nlohmann::json &j, vpKltOpencv &array)
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)
std::vector< cv::Point2f > getFeatures() const
Get the list of current features.