42#include <visp3/core/vpConfig.h>
44#if defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC) && defined(HAVE_OPENCV_VIDEO)
48#include <visp3/core/vpDisplay.h>
49#include <visp3/core/vpTrackingException.h>
50#include <visp3/klt/vpKltOpencv.h>
58 m_termcrit = cv::TermCriteria(cv::TermCriteria::COUNT | cv::TermCriteria::EPS, 20, 0.03);
100 for (
size_t i = 0; i < 2; i++) {
112 for (
size_t i = 0; i <
m_points[1].size(); i++)
122 std::vector<float> err;
128 flags |= cv::OPTFLOW_USE_INITIAL_FLOW;
142 std::vector<uchar> status;
148 for (
int i =
static_cast<int>(status.size()) - 1; i >= 0; i--) {
149 if (status[
static_cast<size_t>(i)] == 0) {
159 if (
static_cast<size_t>(index) >=
m_points[1].size()) {
163 x =
m_points[1][
static_cast<size_t>(index)].x;
164 y =
m_points[1][
static_cast<size_t>(index)].y;
174 const vpColor &color,
unsigned int thickness)
177 for (
size_t i = 0; i < features.size(); i++) {
185 unsigned int thickness)
188 for (
size_t i = 0; i < features.size(); i++) {
196 const std::vector<long> &featuresid,
const vpColor &color,
unsigned int thickness)
199 for (
size_t i = 0; i < features.size(); i++) {
204 std::ostringstream id;
212 const std::vector<long> &featuresid,
const vpColor &color,
unsigned int thickness)
215 for (
size_t i = 0; i < features.size(); i++) {
220 std::ostringstream id;
229 if (guess_pts.size() !=
m_points[1].size()) {
231 "Cannot set initial guess: size feature vector [%d] "
232 "and guess vector [%d] doesn't match",
233 m_points[1].size(), guess_pts.size()));
241 const std::vector<long> &fid)
243 if (guess_pts.size() != init_pts.size()) {
245 "Cannot set initial guess: size init vector [%d] and "
246 "guess vector [%d] doesn't match",
247 init_pts.size(), guess_pts.size()));
262 for (
size_t i = 0; i <
m_points[1].size(); i++) {
275 if (ids.size() != pts.size()) {
277 for (
size_t i = 0; i <
m_points[1].size(); i++)
282 for (
size_t i = 0; i <
m_points[1].size(); i++) {
317 if (
static_cast<size_t>(index) >=
m_points[1].size()) {
328class VISP_EXPORT dummy_vpKltOpencv
331 dummy_vpKltOpencv() { }
334#if !defined(VISP_BUILD_SHARED_LIBS)
336void dummy_vpKltOpenCV_fct() { }
Class to define RGB colors available for display functionalities.
static void displayCross(const vpImage< unsigned char > &I, const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1)
static void displayText(const vpImage< unsigned char > &I, const vpImagePoint &ip, const std::string &s, const vpColor &color)
error that can be emitted by ViSP classes.
@ badValue
Used to indicate that a value is not in the allowed range.
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition of the vpImage class member functions.
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.
int m_blockSize
Block size.
void track(const cv::Mat &I)
double m_minDistance
Mins distance between keypoints.
vpKltOpencv & operator=(const vpKltOpencv ©)
cv::TermCriteria m_termcrit
Term criteria.
double m_minEigThreshold
Min eigen threshold.
void getFeature(const int &index, long &id, float &x, float &y) const
int m_pyrMaxLevel
Pyramid max level.
std::vector< cv::Point2f > m_points[2]
Previous [0] and current [1] keypoint location.
double m_qualityLevel
Quality level.
void suppressFeature(const int &index)
bool m_initial_guess
true when initial guess is provided
cv::Mat m_gray
Gray image.
void setInitialGuess(const std::vector< cv::Point2f > &guess_pts)
void addFeature(const float &x, const float &y)
double m_harris_k
Harris parameter.
void initTracking(const cv::Mat &I, const cv::Mat &mask=cv::Mat())
int m_winSize
Window criteria.
long m_next_points_id
Id for the newt keypoint.
cv::Mat m_prevGray
Previous gray image.
static int round(double x)
Error that can be emitted by the vpTracker class and its derivatives.
@ fatalError
Tracker fatal error.