1 #include <visp3/core/vpConfig.h>
3 #include <visp3/core/vpImageConvert.h>
4 #include <visp3/gui/vpDisplayOpenCV.h>
5 #include <visp3/io/vpVideoReader.h>
6 #include <visp3/klt/vpKltOpencv.h>
10 #if defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC) && defined(HAVE_OPENCV_VIDEO) && defined(HAVE_OPENCV_VIDEOIO)
11 #ifdef ENABLE_VISP_NAMESPACE
45 while (!reader.
end()) {
47 std::cout <<
"Process image " << reader.
getFrameIndex() << std::endl;
55 std::cout <<
"Re initialize the tracker" << std::endl;
58 std::vector<cv::Point2f> prev_features = tracker.
getFeatures();
62 std::vector<cv::Point2f> new_features = tracker.
getFeatures();
66 for (
size_t i = 0; i < prev_features.size(); i++) {
69 bool is_redundant =
false;
70 for (
size_t j = 0; j < new_features.size(); j++) {
71 distance = sqrt(
vpMath::sqr(new_features[j].x - prev_features[i].x) +
72 vpMath::sqr(new_features[j].y - prev_features[i].y));
73 if (distance < minDistance_) {
90 std::cout <<
"tracking of " << tracker.
getNbFeatures() <<
" features" << std::endl;
100 std::cout <<
"Catch an exception: " << e << std::endl;
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 flush(const vpImage< unsigned char > &I)
error that can be emitted by ViSP classes.
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
Wrapper for the KLT (Kanade-Lucas-Tomasi) feature tracker implemented in OpenCV. Thus to enable this ...
void display(const vpImage< unsigned char > &I, const vpColor &color=vpColor::red, unsigned int thickness=1) const
void setBlockSize(int blockSize)
void setQuality(double qualityLevel)
void track(const cv::Mat &I)
int getNbFeatures() const
Get the number of current features.
std::vector< cv::Point2f > getFeatures() const
Get the list of current features.
void setHarrisFreeParameter(double harris_k)
void setMaxFeatures(int maxCount)
void addFeature(const float &x, const float &y)
void initTracking(const cv::Mat &I, const cv::Mat &mask=cv::Mat())
double getMinDistance() const
void setMinDistance(double minDistance)
void setUseHarris(int useHarrisDetector)
void setWindowSize(int winSize)
void setPyramidLevels(int pyrMaxLevel)
static double sqr(double x)
Class that enables to manipulate easily a video file or a sequence of images. As it inherits from the...
void acquire(vpImage< vpRGBa > &I)
void setFileName(const std::string &filename)
long getFrameIndex() const