1 #include <visp3/core/vpImageConvert.h>
4 #include <visp3/klt/vpKltOpencv.h>
5 #include <visp3/gui/vpDisplayOpenCV.h>
6 #include <visp3/io/vpVideoReader.h>
9 int main(
int argc,
const char *argv[])
12 #ifdef VISP_HAVE_OPENCV
15 bool opt_init_by_click =
false;
16 for (
int i=0; i<argc; i++) {
17 if (std::string(argv[i]) ==
"--init-by-click")
18 opt_init_by_click =
true;
19 else if (std::string(argv[i]) ==
"--help") {
20 std::cout <<
"Usage: " << argv[0] <<
" [--init-by-click] [--help]" << std::endl;
36 #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
37 IplImage * cvI = NULL;
65 if (opt_init_by_click) {
67 #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
68 std::vector<CvPoint2D32f> feature;
70 std::vector<cv::Point2f> feature;
75 "Left click to select a point, right to start tracking",
79 feature.push_back(cv::Point2f((
float)ip.
get_u(), (float)ip.
get_v()));
86 #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
99 std::cout <<
"Tracker initialized with " << tracker.
getNbFeatures() <<
" features" << std::endl;
103 while ( ! reader.
end() )
112 #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
113 std::vector<CvPoint2D32f> feature;
115 std::vector<cv::Point2f> feature;
120 "Left click to select a point, right to start tracking",
124 feature.push_back(cv::Point2f((
float)ip.
get_u(), (float)ip.
get_v()));
131 #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
150 #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
151 cvReleaseImage(&cvI);
158 std::cout <<
"Catch an exception: " << e << std::endl;
VISP_EXPORT int wait(double t0, double t)
long getFrameIndex() const
long getFirstFrameIndex() const
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
void setHarrisFreeParameter(double harris_k)
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
void setMaxFeatures(const int maxCount)
static void displayText(const vpImage< unsigned char > &I, const vpImagePoint &ip, const std::string &s, const vpColor &color)
Class that enables to manipulate easily a video file or a sequence of images. As it inherits from the...
void setMinDistance(double minDistance)
error that can be emited by ViSP classes.
static const vpColor green
static void flush(const vpImage< unsigned char > &I)
void display(const vpImage< unsigned char > &I, const vpColor &color=vpColor::red, unsigned int thickness=1)
void setQuality(double qualityLevel)
static void display(const vpImage< unsigned char > &I)
The vpDisplayOpenCV allows to display image using the OpenCV library. Thus to enable this class OpenC...
void acquire(vpImage< vpRGBa > &I)
void setFileName(const char *filename)
void initTracking(const cv::Mat &I, const cv::Mat &mask=cv::Mat())
void setPyramidLevels(const int pyrMaxLevel)
static void displayCross(const vpImage< unsigned char > &I, const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1)
void setWindowSize(const int winSize)
Wrapper for the KLT (Kanade-Lucas-Tomasi) feature tracker implemented in OpenCV. Thus to enable this ...
void setBlockSize(const int blockSize)
int getNbFeatures() const
Get the number of current features.
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
void setUseHarris(const int useHarrisDetector)
void track(const cv::Mat &I)