Visual Servoing Platform version 3.7.0
Loading...
Searching...
No Matches

#include <vpKltOpencv.h>

Public Member Functions

 vpKltOpencv ()
 vpKltOpencv (const vpKltOpencv &copy)
virtual ~vpKltOpencv ()
void addFeature (const float &x, const float &y)
void addFeature (const long &id, const float &x, const float &y)
void addFeature (const cv::Point2f &f)
void display (const vpImage< unsigned char > &I, const vpColor &color=vpColor::red, unsigned int thickness=1) const
int getBlockSize () const
void getFeature (const int &index, long &id, float &x, float &y) const
std::vector< cv::Point2f > getFeatures () const
std::vector< long > getFeaturesId () const
double getHarrisFreeParameter () const
int getMaxFeatures () const
double getMinDistance () const
int getNbFeatures () const
int getNbPrevFeatures () const
std::vector< cv::Point2f > getPrevFeatures () const
int getPyramidLevels () const
double getQuality () const
int getWindowSize () const
void initTracking (const cv::Mat &I, const cv::Mat &mask=cv::Mat())
void initTracking (const cv::Mat &I, const std::vector< cv::Point2f > &pts)
void initTracking (const cv::Mat &I, const std::vector< cv::Point2f > &pts, const std::vector< long > &ids)
vpKltOpencvoperator= (const vpKltOpencv &copy)
void track (const cv::Mat &I)
void setBlockSize (int blockSize)
void setHarrisFreeParameter (double harris_k)
void setInitialGuess (const std::vector< cv::Point2f > &guess_pts)
void setInitialGuess (const std::vector< cv::Point2f > &init_pts, const std::vector< cv::Point2f > &guess_pts, const std::vector< long > &fid)
void setMaxFeatures (int maxCount)
void setMinDistance (double minDistance)
void setMinEigThreshold (double minEigThreshold)
void setPyramidLevels (int pyrMaxLevel)
void setQuality (double qualityLevel)
void setTrackerId (int tid)
void setUseHarris (int useHarrisDetector)
void setWindowSize (int winSize)
void suppressFeature (const int &index)

Static Public Member Functions

static void display (const vpImage< unsigned char > &I, const std::vector< cv::Point2f > &features, const vpColor &color=vpColor::green, unsigned int thickness=1)
static void display (const vpImage< vpRGBa > &I, const std::vector< cv::Point2f > &features, const vpColor &color=vpColor::green, unsigned int thickness=1)
static void display (const vpImage< unsigned char > &I, const std::vector< cv::Point2f > &features, const std::vector< long > &featuresid, const vpColor &color=vpColor::green, unsigned int thickness=1)
static void display (const vpImage< vpRGBa > &I, const std::vector< cv::Point2f > &features, const std::vector< long > &featuresid, const vpColor &color=vpColor::green, unsigned int thickness=1)

Protected Attributes

cv::Mat m_gray
cv::Mat m_prevGray
std::vector< cv::Point2f > m_points [2]
std::vector< long > m_points_id
int m_maxCount
cv::TermCriteria m_termcrit
int m_winSize
double m_qualityLevel
double m_minDistance
double m_minEigThreshold
double m_harris_k
int m_blockSize
int m_useHarrisDetector
int m_pyrMaxLevel
long m_next_points_id
bool m_initial_guess

Friends

void to_json (nlohmann::json &j, const vpKltOpencv &array)
void from_json (const nlohmann::json &j, vpKltOpencv &array)

Detailed Description

Wrapper for the KLT (Kanade-Lucas-Tomasi) feature tracker implemented in OpenCV. Thus to enable this class OpenCV should be installed. Installation instructions are provided here https://visp.inria.fr/3rd_opencv.

Tutorials & Examples

Tutorials

The following example available in tutorial-klt-tracker.cpp shows how to use the main functions of the class.

#include <iostream>
#include <visp3/core/vpConfig.h>
#if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC) && defined(HAVE_OPENCV_VIDEO) && defined(HAVE_OPENCV_VIDEOIO)
#include <visp3/core/vpImageConvert.h>
#include <visp3/gui/vpDisplayOpenCV.h>
#include <visp3/io/vpVideoReader.h>
#include <visp3/klt/vpKltOpencv.h>
int main(int argc, const char *argv[])
{
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif
try {
std::string opt_videoname = "video-postcard.mp4";
bool opt_init_by_click = false;
unsigned int opt_subsample = 1;
for (int i = 1; i < argc; i++) {
if (std::string(argv[i]) == "--videoname") {
opt_videoname = std::string(argv[++i]);
}
else if (std::string(argv[i]) == "--init-by-click") {
opt_init_by_click = true;
}
else if (std::string(argv[i]) == "--subsample") {
opt_subsample = static_cast<unsigned int>(std::atoi(argv[++i]));
}
else if (std::string(argv[i]) == "--help" || std::string(argv[i]) == "-h") {
std::cout << "Usage: " << argv[0]
<< " [--videoname <video name>] [--subsample <scale factor>] [--init-by-click]"
<< " [--help] [-h]" << std::endl;
return EXIT_SUCCESS;
}
}
vpVideoReader reader;
reader.setFileName(opt_videoname);
reader.acquire(Iacq);
Iacq.subsample(opt_subsample, opt_subsample, I);
cv::Mat cvI;
vpDisplayOpenCV d(I, 0, 0, "Klt tracking");
tracker.setMaxFeatures(200);
tracker.setWindowSize(10);
tracker.setQuality(0.01);
tracker.setMinDistance(15);
tracker.setHarrisFreeParameter(0.04);
tracker.setBlockSize(9);
tracker.setUseHarris(1);
tracker.setPyramidLevels(3);
// Initialise the tracking
if (opt_init_by_click) {
std::vector<cv::Point2f> feature;
do {
vpDisplay::displayText(I, 10, 10, "Left click to select a point, right to start tracking", vpColor::red);
if (vpDisplay::getClick(I, ip, button, false)) {
if (button == vpMouseButton::button1) {
feature.push_back(cv::Point2f(static_cast<float>(ip.get_u()), static_cast<float>(ip.get_v())));
}
}
} while (button != vpMouseButton::button3);
tracker.initTracking(cvI, feature);
}
else {
tracker.initTracking(cvI);
}
std::cout << "Tracker initialized with " << tracker.getNbFeatures() << " features" << std::endl;
while (!reader.end()) {
reader.acquire(Iacq);
Iacq.subsample(opt_subsample, opt_subsample, I);
if (opt_init_by_click && reader.getFrameIndex() == reader.getFirstFrameIndex() + 20) {
std::vector<cv::Point2f> feature;
do {
vpDisplay::displayText(I, 10, 10, "Left click to select a point, right to start tracking", vpColor::red);
if (vpDisplay::getClick(I, ip, button, false)) {
if (button == vpMouseButton::button1) {
feature.push_back(cv::Point2f(static_cast<float>(ip.get_u()), static_cast<float>(ip.get_v())));
}
}
} while (button != vpMouseButton::button3);
tracker.initTracking(cvI, feature);
}
tracker.track(cvI);
tracker.display(I, vpColor::red);
vpDisplay::displayText(I, 10, 10, "Click to quit", vpColor::red);
if (vpDisplay::getClick(I, false))
break;
if (!reader.isVideoFormat()) {
vpTime::wait(t, 40);
}
}
}
catch (const vpException &e) {
std::cout << "Catch an exception: " << e << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
#else
int main()
{
#if !defined(HAVE_OPENCV_HIGHGUI)
std::cout << "This tutorial needs OpenCV highgui module that is missing." << std::endl;
#endif
#if !defined(HAVE_OPENCV_IMGPROC)
std::cout << "This tutorial needs OpenCV imgproc module that is missing." << std::endl;
#endif
#if !defined(HAVE_OPENCV_VIDEO)
std::cout << "This tutorial needs OpenCV video module that is missing." << std::endl;
#endif
#if !defined(HAVE_OPENCV_VIDEOIO)
std::cout << "This tutorial needs OpenCV videoio module that is missing." << std::endl;
#endif
}
#endif
static const vpColor red
Definition vpColor.h:198
static const vpColor green
Definition vpColor.h:201
The vpDisplayOpenCV allows to display image using the OpenCV library. Thus to enable this class OpenC...
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
static void display(const vpImage< unsigned char > &I)
static void displayCross(const vpImage< unsigned char > &I, const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1)
static void flush(const vpImage< unsigned char > &I)
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.
Definition vpException.h:60
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
double get_u() const
double get_v() const
Definition of the vpImage class member functions.
Definition vpImage.h:131
void subsample(unsigned int v_scale, unsigned int h_scale, vpImage< Type > &sampled) const
Definition vpImage.h:755
Wrapper for the KLT (Kanade-Lucas-Tomasi) feature tracker implemented in OpenCV. Thus to enable this ...
Definition vpKltOpencv.h:83
Class that enables to manipulate easily a video file or a sequence of images. As it inherits from the...
bool isVideoFormat() const
void setFileName(const std::string &filename)
long getFirstFrameIndex()
long getFrameIndex() const
void acquire(vpImage< vpRGBa > &I) VP_OVERRIDE
VISP_EXPORT double measureTimeMs()
VISP_EXPORT int wait(double t0, double t)

A line by line explanation is provided in Tutorial: Keypoint tracking.

Examples
catchGenericTrackerDeterminist.cpp, mbtEdgeKltTracking.cpp, mbtGenericTracking.cpp, mbtGenericTracking2.cpp, mbtGenericTrackingDepth.cpp, mbtKltTracking.cpp, perfGenericTracker.cpp, testGenericTracker.cpp, trackKltOpencv.cpp, tutorial-klt-tracker-live.cpp, tutorial-klt-tracker-with-reinit.cpp, tutorial-klt-tracker.cpp, tutorial-mb-generic-tracker-apriltag-rs2.cpp, tutorial-mb-generic-tracker-apriltag-webcam.cpp, tutorial-mb-generic-tracker-full.cpp, tutorial-mb-generic-tracker-live.cpp, tutorial-mb-generic-tracker-rgbd.cpp, tutorial-mb-generic-tracker-stereo-mono.cpp, tutorial-mb-generic-tracker.cpp, tutorial-mb-hybrid-tracker.cpp, tutorial-mb-klt-tracker.cpp, tutorial-mb-tracker-full.cpp, and tutorial-mb-tracker.cpp.

Definition at line 82 of file vpKltOpencv.h.

Constructor & Destructor Documentation

◆ vpKltOpencv() [1/2]

◆ vpKltOpencv() [2/2]

◆ ~vpKltOpencv()

vpKltOpencv::~vpKltOpencv ( )
virtual

Destructor.

Definition at line 92 of file vpKltOpencv.cpp.

Member Function Documentation

◆ addFeature() [1/3]

void vpKltOpencv::addFeature ( const cv::Point2f & f)

Add a keypoint at the end of the feature list. The id of the feature is set to ensure that it is unique.

Parameters
f: Coordinates of the feature in the image.

Definition at line 309 of file vpKltOpencv.cpp.

References m_next_points_id, m_points, and m_points_id.

◆ addFeature() [2/3]

void vpKltOpencv::addFeature ( const float & x,
const float & y )

Add a keypoint at the end of the feature list. The id of the feature is set to ensure that it is unique.

Parameters
x: Coordinates along x-axis of the feature in the image.
y: Coordinates along y-axis of the feature in the image.

Definition at line 293 of file vpKltOpencv.cpp.

References m_next_points_id, m_points, and m_points_id.

◆ addFeature() [3/3]

void vpKltOpencv::addFeature ( const long & id,
const float & x,
const float & y )

Add a keypoint at the end of the feature list.

Warning
This function doesn't ensure that the id of the feature is unique. You should rather use addFeature(const float &, const float &) or addFeature(const cv::Point2f &).
Parameters
id: Feature id. Should be unique
x: Coordinates along x-axis of the feature in the image.
y: Coordinates along y-axis of the feature in the image.

Definition at line 300 of file vpKltOpencv.cpp.

References m_next_points_id, m_points, and m_points_id.

◆ display() [1/5]

void vpKltOpencv::display ( const vpImage< unsigned char > & I,
const std::vector< cv::Point2f > & features,
const std::vector< long > & featuresid,
const vpColor & color = vpColor::green,
unsigned int thickness = 1 )
static

Display features list with ids.

Parameters
I: The image used as background.
features: Vector of features.
featuresid: Vector of ids corresponding to the features.
color: Color used to display the points.
thickness: Thickness of the points

Definition at line 195 of file vpKltOpencv.cpp.

References vpDisplay::displayCross(), vpDisplay::displayText(), vpMath::round(), vpImagePoint::set_u(), and vpImagePoint::set_v().

◆ display() [2/5]

void vpKltOpencv::display ( const vpImage< unsigned char > & I,
const std::vector< cv::Point2f > & features,
const vpColor & color = vpColor::green,
unsigned int thickness = 1 )
static

Display features list.

Parameters
I: The image used as background.
features: Vector of features.
color: Color used to display the points.
thickness: Thickness of the points.

Definition at line 173 of file vpKltOpencv.cpp.

References vpDisplay::displayCross(), vpMath::round(), vpImagePoint::set_u(), and vpImagePoint::set_v().

◆ display() [3/5]

void vpKltOpencv::display ( const vpImage< unsigned char > & I,
const vpColor & color = vpColor::red,
unsigned int thickness = 1 ) const

Display features position and id.

Parameters
I: Image used as background. Display should be initialized on it.
color: Color used to display the features.
thickness: Thickness of the drawings.

Definition at line 168 of file vpKltOpencv.cpp.

References display(), m_points, and m_points_id.

Referenced by display().

◆ display() [4/5]

void vpKltOpencv::display ( const vpImage< vpRGBa > & I,
const std::vector< cv::Point2f > & features,
const std::vector< long > & featuresid,
const vpColor & color = vpColor::green,
unsigned int thickness = 1 )
static

Display features list with ids.

Parameters
I: The image used as background.
features: Vector of features.
featuresid: Vector of ids corresponding to the features.
color: Color used to display the points.
thickness: Thickness of the points

Definition at line 211 of file vpKltOpencv.cpp.

References vpDisplay::displayCross(), vpDisplay::displayText(), vpMath::round(), vpImagePoint::set_u(), and vpImagePoint::set_v().

◆ display() [5/5]

void vpKltOpencv::display ( const vpImage< vpRGBa > & I,
const std::vector< cv::Point2f > & features,
const vpColor & color = vpColor::green,
unsigned int thickness = 1 )
static

Display features list.

Parameters
I: The image used as background.
features: Vector of features.
color: Color used to display the points.
thickness: Thickness of the points.

Definition at line 184 of file vpKltOpencv.cpp.

References vpDisplay::displayCross(), vpMath::round(), vpImagePoint::set_u(), and vpImagePoint::set_v().

◆ getBlockSize()

int vpKltOpencv::getBlockSize ( ) const
inline

Get the size of the averaging block used to track the features.

Definition at line 181 of file vpKltOpencv.h.

References m_blockSize.

Referenced by to_json.

◆ getFeature()

void vpKltOpencv::getFeature ( const int & index,
long & id,
float & x,
float & y ) const

Get the 'index'th feature image coordinates. Beware that getFeature(i,...) may not represent the same feature before and after a tracking iteration (if a feature is lost, features are shifted in the array).

Parameters
index: Index of feature.
id: id of the feature.
x: x coordinate.
y: y coordinate.

Definition at line 157 of file vpKltOpencv.cpp.

References vpException::badValue, m_points, and m_points_id.

Referenced by vpMbtDistanceKltCylinder::computeNbDetectedCurrent(), vpMbtDistanceKltPoints::computeNbDetectedCurrent(), vpMbtDistanceKltCylinder::init(), and vpMbtDistanceKltPoints::init().

◆ getFeatures()

std::vector< cv::Point2f > vpKltOpencv::getFeatures ( ) const
inline

Get the list of current features.

Definition at line 195 of file vpKltOpencv.h.

References m_points.

◆ getFeaturesId()

std::vector< long > vpKltOpencv::getFeaturesId ( ) const
inline

Get the unique id of each feature.

Definition at line 198 of file vpKltOpencv.h.

References m_points_id.

◆ getHarrisFreeParameter()

double vpKltOpencv::getHarrisFreeParameter ( ) const
inline

Get the free parameter of the Harris detector.

Definition at line 201 of file vpKltOpencv.h.

References m_harris_k.

Referenced by to_json.

◆ getMaxFeatures()

int vpKltOpencv::getMaxFeatures ( ) const
inline

Get the list of lost feature.

Get the maximum number of features to track in the image.

Definition at line 205 of file vpKltOpencv.h.

References m_maxCount.

Referenced by to_json.

◆ getMinDistance()

double vpKltOpencv::getMinDistance ( ) const
inline

Get the minimal Euclidean distance between detected corners during initialization.

Definition at line 208 of file vpKltOpencv.h.

References m_minDistance.

Referenced by to_json.

◆ getNbFeatures()

int vpKltOpencv::getNbFeatures ( ) const
inline

◆ getNbPrevFeatures()

int vpKltOpencv::getNbPrevFeatures ( ) const
inline

Get the number of previous features.

Definition at line 212 of file vpKltOpencv.h.

References m_points.

◆ getPrevFeatures()

std::vector< cv::Point2f > vpKltOpencv::getPrevFeatures ( ) const
inline

Get the list of previous features.

Definition at line 215 of file vpKltOpencv.h.

References m_points.

◆ getPyramidLevels()

int vpKltOpencv::getPyramidLevels ( ) const
inline

Get the list of features id.

Get the maximal pyramid level.

Definition at line 220 of file vpKltOpencv.h.

References m_pyrMaxLevel.

Referenced by to_json.

◆ getQuality()

double vpKltOpencv::getQuality ( ) const
inline

Get the parameter characterizing the minimal accepted quality of image corners.

Definition at line 223 of file vpKltOpencv.h.

References m_qualityLevel.

Referenced by to_json.

◆ getWindowSize()

int vpKltOpencv::getWindowSize ( ) const
inline

Get the window size used to refine the corner locations.

Definition at line 225 of file vpKltOpencv.h.

References m_winSize.

Referenced by to_json.

◆ initTracking() [1/3]

void vpKltOpencv::initTracking ( const cv::Mat & I,
const cv::Mat & mask = cv::Mat() )

Initialise the tracking by extracting KLT keypoints on the provided image.

Parameters
I: Grey level image used as input. This image should have only 1 channel.
mask: Image mask used to restrict the keypoint detection area. If mask is nullptr, all the image will be considered.
Exceptions
vpTrackingException::initializationError: If the image I is not initialized, or if the image or the mask have bad coding format.

Definition at line 94 of file vpKltOpencv.cpp.

References m_blockSize, m_gray, m_harris_k, m_maxCount, m_minDistance, m_next_points_id, m_points, m_points_id, m_qualityLevel, m_termcrit, and m_winSize.

◆ initTracking() [2/3]

void vpKltOpencv::initTracking ( const cv::Mat & I,
const std::vector< cv::Point2f > & pts )

Set the points that will be used as initialization during the next call to track().

Parameters
I: Input image.
pts: Vector of points that should be tracked.

Definition at line 256 of file vpKltOpencv.cpp.

References m_gray, m_initial_guess, m_next_points_id, m_points, and m_points_id.

◆ initTracking() [3/3]

void vpKltOpencv::initTracking ( const cv::Mat & I,
const std::vector< cv::Point2f > & pts,
const std::vector< long > & ids )

Set the points that will be used as initialization during the next call to track().

Parameters
I: Input image.
pts: Vector of points that should be tracked.
ids: Corresponding point ids.

Definition at line 269 of file vpKltOpencv.cpp.

References m_gray, m_initial_guess, m_next_points_id, m_points, and m_points_id.

◆ operator=()

◆ setBlockSize()

void vpKltOpencv::setBlockSize ( int blockSize)
inline

Set the size of the averaging block used to track the features.

Warning
The input is a signed integer to be compatible with OpenCV. However, it must be a positive integer.
Parameters
blockSize: Size of an average block for computing a derivative covariance matrix over each pixel neighborhood. Default value is set to 3.
Examples
catchGenericTrackerDeterminist.cpp, mbtEdgeKltTracking.cpp, mbtGenericTracking.cpp, mbtGenericTracking2.cpp, mbtGenericTrackingDepth.cpp, mbtKltTracking.cpp, perfGenericTracker.cpp, testGenericTracker.cpp, tutorial-mb-generic-tracker-apriltag-rs2.cpp, tutorial-mb-generic-tracker-apriltag-webcam.cpp, tutorial-mb-generic-tracker-full.cpp, tutorial-mb-generic-tracker-live.cpp, tutorial-mb-generic-tracker-rgbd.cpp, tutorial-mb-generic-tracker-stereo-mono.cpp, tutorial-mb-generic-tracker.cpp, tutorial-mb-hybrid-tracker.cpp, tutorial-mb-klt-tracker.cpp, tutorial-mb-tracker-full.cpp, and tutorial-mb-tracker.cpp.

Definition at line 279 of file vpKltOpencv.h.

References m_blockSize.

Referenced by from_json.

◆ setHarrisFreeParameter()

◆ setInitialGuess() [1/2]

void vpKltOpencv::setInitialGuess ( const std::vector< cv::Point2f > & guess_pts)

Set the points that will be used as initial guess during the next call to track(). A typical usage of this function is to predict the position of the features before the next call to track().

Parameters
guess_pts: Vector of points that should be tracked. The size of this vector should be the same as the one returned by getFeatures(). If this is not the case, an exception is returned. Note also that the id of the points is not modified.
See also
initTracking()

Definition at line 227 of file vpKltOpencv.cpp.

References vpException::badValue, m_initial_guess, and m_points.

◆ setInitialGuess() [2/2]

void vpKltOpencv::setInitialGuess ( const std::vector< cv::Point2f > & init_pts,
const std::vector< cv::Point2f > & guess_pts,
const std::vector< long > & fid )

Set the points that will be used as initial guess during the next call to track(). A typical usage of this function is to predict the position of the features before the next call to track().

Parameters
init_pts: Initial points (could be obtained from getPrevFeatures() or getFeatures()).
guess_pts: Prediction of the new position of the initial points. The size of this vector must be the same as the size of the vector of initial points.
fid: Identifiers of the initial points.
See also
getPrevFeatures(),getPrevFeaturesId
getFeatures(), getFeaturesId
initTracking()

Definition at line 240 of file vpKltOpencv.cpp.

References vpException::badValue, m_initial_guess, m_points, and m_points_id.

◆ setMaxFeatures()

◆ setMinDistance()

◆ setMinEigThreshold()

void vpKltOpencv::setMinEigThreshold ( double minEigThreshold)
inline

Set the minimal eigen value threshold used to reject a point during the tracking.

Parameters
minEigThreshold: Minimal eigen value threshold. Default value is set to 1e-4.

Definition at line 345 of file vpKltOpencv.h.

References m_minEigThreshold.

◆ setPyramidLevels()

void vpKltOpencv::setPyramidLevels ( int pyrMaxLevel)
inline

◆ setQuality()

void vpKltOpencv::setQuality ( double qualityLevel)
inline

Set the parameter characterizing the minimal accepted quality of image corners.

Parameters
qualityLevel: Quality level parameter. Default value is set to 0.01. The parameter value is multiplied by the best corner quality measure, which is the minimal eigenvalue or the Harris function response. The corners with the quality measure less than the product are rejected. For example, if the best corner has the quality measure = 1500, and the qualityLevel=0.01, then all the corners with the quality measure less than 15 are rejected.
Examples
catchGenericTrackerDeterminist.cpp, mbtEdgeKltTracking.cpp, mbtGenericTracking.cpp, mbtGenericTracking2.cpp, mbtGenericTrackingDepth.cpp, mbtKltTracking.cpp, perfGenericTracker.cpp, testGenericTracker.cpp, tutorial-mb-generic-tracker-apriltag-rs2.cpp, tutorial-mb-generic-tracker-apriltag-webcam.cpp, tutorial-mb-generic-tracker-full.cpp, tutorial-mb-generic-tracker-live.cpp, tutorial-mb-generic-tracker-rgbd.cpp, tutorial-mb-generic-tracker-stereo-mono.cpp, tutorial-mb-generic-tracker.cpp, tutorial-mb-hybrid-tracker.cpp, tutorial-mb-klt-tracker.cpp, tutorial-mb-tracker-full.cpp, and tutorial-mb-tracker.cpp.

Definition at line 368 of file vpKltOpencv.h.

References m_qualityLevel.

Referenced by from_json.

◆ setTrackerId()

void vpKltOpencv::setTrackerId ( int tid)
inline

Does nothing. Just here for compat with previous releases that use OpenCV C api to do the tracking.

Definition at line 372 of file vpKltOpencv.h.

◆ setUseHarris()

void vpKltOpencv::setUseHarris ( int useHarrisDetector)
inline

Set the parameter indicating whether to use a Harris detector or the minimal eigenvalue of gradient matrices for corner detection.

Parameters
useHarrisDetector: If 1 (default value), use the Harris detector. If 0 use the eigenvalue.

Definition at line 380 of file vpKltOpencv.h.

References m_useHarrisDetector.

Referenced by from_json.

◆ setWindowSize()

◆ suppressFeature()

void vpKltOpencv::suppressFeature ( const int & index)

Remove the feature with the given index as parameter.

Parameters
index: Index of the feature to remove.

Definition at line 315 of file vpKltOpencv.cpp.

References vpException::badValue, m_points, and m_points_id.

◆ track()

void vpKltOpencv::track ( const cv::Mat & I)

Track KLT keypoints using the iterative Lucas-Kanade method with pyramids.

Parameters
I: Input image.

Definition at line 117 of file vpKltOpencv.cpp.

References vpTrackingException::fatalError, m_gray, m_initial_guess, m_minEigThreshold, m_points, m_points_id, m_prevGray, m_pyrMaxLevel, m_termcrit, and m_winSize.

◆ from_json

void from_json ( const nlohmann::json & j,
vpKltOpencv & array )
friend

◆ to_json

void to_json ( nlohmann::json & j,
const vpKltOpencv & array )
friend

Member Data Documentation

◆ m_blockSize

int vpKltOpencv::m_blockSize
protected

Block size.

Definition at line 415 of file vpKltOpencv.h.

Referenced by getBlockSize(), initTracking(), operator=(), setBlockSize(), vpKltOpencv(), and vpKltOpencv().

◆ m_gray

cv::Mat vpKltOpencv::m_gray
protected

Gray image.

Definition at line 404 of file vpKltOpencv.h.

Referenced by initTracking(), initTracking(), initTracking(), operator=(), track(), vpKltOpencv(), and vpKltOpencv().

◆ m_harris_k

double vpKltOpencv::m_harris_k
protected

Harris parameter.

Definition at line 414 of file vpKltOpencv.h.

Referenced by getHarrisFreeParameter(), initTracking(), operator=(), setHarrisFreeParameter(), vpKltOpencv(), and vpKltOpencv().

◆ m_initial_guess

bool vpKltOpencv::m_initial_guess
protected

true when initial guess is provided

Definition at line 419 of file vpKltOpencv.h.

Referenced by initTracking(), initTracking(), operator=(), setInitialGuess(), setInitialGuess(), track(), vpKltOpencv(), and vpKltOpencv().

◆ m_maxCount

int vpKltOpencv::m_maxCount
protected

Max number of keypoints.

Definition at line 408 of file vpKltOpencv.h.

Referenced by getMaxFeatures(), initTracking(), operator=(), setMaxFeatures(), vpKltOpencv(), and vpKltOpencv().

◆ m_minDistance

double vpKltOpencv::m_minDistance
protected

Mins distance between keypoints.

Definition at line 412 of file vpKltOpencv.h.

Referenced by getMinDistance(), initTracking(), operator=(), setMinDistance(), vpKltOpencv(), and vpKltOpencv().

◆ m_minEigThreshold

double vpKltOpencv::m_minEigThreshold
protected

Min eigen threshold.

Definition at line 413 of file vpKltOpencv.h.

Referenced by operator=(), setMinEigThreshold(), track(), vpKltOpencv(), and vpKltOpencv().

◆ m_next_points_id

long vpKltOpencv::m_next_points_id
protected

Id for the newt keypoint.

Definition at line 418 of file vpKltOpencv.h.

Referenced by addFeature(), addFeature(), addFeature(), initTracking(), initTracking(), initTracking(), operator=(), vpKltOpencv(), and vpKltOpencv().

◆ m_points

std::vector<cv::Point2f> vpKltOpencv::m_points[2]
protected

◆ m_points_id

std::vector<long> vpKltOpencv::m_points_id
protected

◆ m_prevGray

cv::Mat vpKltOpencv::m_prevGray
protected

Previous gray image.

Definition at line 405 of file vpKltOpencv.h.

Referenced by operator=(), track(), vpKltOpencv(), and vpKltOpencv().

◆ m_pyrMaxLevel

int vpKltOpencv::m_pyrMaxLevel
protected

Pyramid max level.

Definition at line 417 of file vpKltOpencv.h.

Referenced by getPyramidLevels(), operator=(), setPyramidLevels(), track(), vpKltOpencv(), and vpKltOpencv().

◆ m_qualityLevel

double vpKltOpencv::m_qualityLevel
protected

Quality level.

Definition at line 411 of file vpKltOpencv.h.

Referenced by getQuality(), initTracking(), operator=(), setQuality(), vpKltOpencv(), and vpKltOpencv().

◆ m_termcrit

cv::TermCriteria vpKltOpencv::m_termcrit
protected

Term criteria.

Definition at line 409 of file vpKltOpencv.h.

Referenced by initTracking(), operator=(), track(), vpKltOpencv(), and vpKltOpencv().

◆ m_useHarrisDetector

int vpKltOpencv::m_useHarrisDetector
protected

true to use Harris detector

Definition at line 416 of file vpKltOpencv.h.

Referenced by operator=(), setUseHarris(), to_json, vpKltOpencv(), and vpKltOpencv().

◆ m_winSize

int vpKltOpencv::m_winSize
protected

Window criteria.

Definition at line 410 of file vpKltOpencv.h.

Referenced by getWindowSize(), initTracking(), operator=(), setWindowSize(), track(), vpKltOpencv(), and vpKltOpencv().