2 #include <visp/vpImageConvert.h>
3 #include <visp/vpKltOpencv.h>
4 #include <visp/vpDisplayOpenCV.h>
5 #include <visp/vpVideoReader.h>
6 #include <visp/vpV4l2Grabber.h>
8 int main(
int argc,
const char *argv[])
10 #if defined(VISP_HAVE_OPENCV) && (defined(VISP_HAVE_V4L2) || (VISP_HAVE_OPENCV_VERSION >= 0x020100))
12 bool opt_init_by_click =
false;
15 for (
int i=0; i<argc; i++) {
16 if (std::string(argv[i]) ==
"--init-by-click")
17 opt_init_by_click =
true;
18 else if (std::string(argv[i]) ==
"--device")
19 opt_device = atoi(argv[i+1]);
20 else if (std::string(argv[i]) ==
"--help") {
21 std::cout <<
"Usage: " << argv[0] <<
" [--init-by-click] [--device <camera device>] [--help]" << std::endl;
28 #if defined(VISP_HAVE_V4L2)
30 std::ostringstream device;
31 device <<
"/dev/video" << opt_device;
35 #elif defined(VISP_HAVE_OPENCV)
36 cv::VideoCapture g(opt_device);
38 std::cout <<
"Failed to open the camera" << std::endl;
46 #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
47 IplImage * cvI = NULL;
70 if (opt_init_by_click) {
71 #if (VISP_HAVE_OPENCV_VERSION >= 0x020408)
73 std::vector<cv::Point2f> guess;
79 guess.push_back(cv::Point2f((
float)ip.
get_u(), (float)ip.
get_v()));
95 #if defined(VISP_HAVE_V4L2)
97 #elif defined(VISP_HAVE_OPENCV)
113 #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
114 cvReleaseImage(&cvI);
120 std::cout <<
"Catch an exception: " << e << std::endl;
void acquire(vpImage< unsigned char > &I)
void open(vpImage< unsigned char > &I)
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)
void setDevice(const std::string &devname)
void setMinDistance(double minDistance)
error that can be emited by ViSP classes.
static int wait(double t0, double t)
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.
virtual void displayCross(const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1)=0
void initTracking(const cv::Mat &I, const cv::Mat &mask=cv::Mat())
void setPyramidLevels(const int pyrMaxLevel)
Class for the Video4Linux2 video device.
void setWindowSize(const int winSize)
Wrapper for the KLT (Kanade-Lucas-Tomasi) feature tracker implemented in OpenCV.
void setBlockSize(const int blockSize)
virtual bool getClick(bool blocking=true)=0
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)