39 #include <visp3/core/vpConfig.h> 50 #include <visp3/core/vpConfig.h> 52 #if defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100) 54 #include <visp3/core/vpImage.h> 55 #include <visp3/core/vpImageConvert.h> 56 #include <visp3/gui/vpDisplayOpenCV.h> 57 #include <visp3/sensor/vpOpenCVGrabber.h> 62 int main(
int argc,
char **argv)
67 device = atoi(argv[1]);
69 std::cout <<
"Use device: " << device << std::endl;
70 cv::VideoCapture cap(device);
71 #if (VISP_HAVE_OPENCV_VERSION >= 0x030000) 72 cap.set(cv::CAP_PROP_FRAME_WIDTH, 640);
73 cap.set(cv::CAP_PROP_FRAME_HEIGHT, 480);
75 cap.set(CV_CAP_PROP_FRAME_WIDTH, 640);
76 cap.set(CV_CAP_PROP_FRAME_HEIGHT, 480);
82 while ((i++ < 100) && !cap.read(frame)) {
85 std::cout <<
"Image size: " 86 #if (VISP_HAVE_OPENCV_VERSION >= 0x030000) 87 << (int)cap.get(cv::CAP_PROP_FRAME_WIDTH) <<
" " << (int)cap.get(cv::CAP_PROP_FRAME_HEIGHT) << std::endl;
89 << (int)cap.get(CV_CAP_PROP_FRAME_WIDTH) <<
" " << (int)cap.get(CV_CAP_PROP_FRAME_HEIGHT) << std::endl;
112 std::cout <<
"Catch an exception: " << e << std::endl;
120 std::cout <<
"You do not have OpenCV functionalities to display images..." << std::endl;
121 std::cout <<
"Tip:" << std::endl;
122 std::cout <<
"- Install OpenCV, configure again ViSP using cmake and build again this example" << std::endl;
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
error that can be emited by ViSP classes.
static void flush(const vpImage< unsigned char > &I)
static void display(const vpImage< unsigned char > &I)
The vpDisplayOpenCV allows to display image using the OpenCV library. Thus to enable this class OpenC...