4 #include <visp3/core/vpConfig.h>
17 #if defined(VISP_HAVE_DISPLAY) && \
18 (defined(VISP_HAVE_V4L2) || defined(VISP_HAVE_DC1394) || defined(VISP_HAVE_CMU1394) || \
19 defined(VISP_HAVE_FLYCAPTURE) || defined(VISP_HAVE_REALSENSE2) || \
20 ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI)) || ((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_VIDEOIO)))
22 #ifdef VISP_HAVE_MODULE_SENSOR
23 #include <visp3/sensor/vp1394CMUGrabber.h>
24 #include <visp3/sensor/vp1394TwoGrabber.h>
25 #include <visp3/sensor/vpFlyCaptureGrabber.h>
26 #include <visp3/sensor/vpRealSense2.h>
27 #include <visp3/sensor/vpV4l2Grabber.h>
29 #include <visp3/blob/vpDot2.h>
30 #include <visp3/gui/vpDisplayFactory.h>
32 #if (VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI)
33 #include <opencv2/highgui/highgui.hpp>
34 #elif (VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_VIDEOIO)
35 #include <opencv2/videoio/videoio.hpp>
40 #ifdef ENABLE_VISP_NAMESPACE
48 #if defined(VISP_HAVE_V4L2)
50 std::ostringstream device;
51 device <<
"/dev/video" << opt_device;
52 std::cout <<
"Use Video 4 Linux grabber on device " << device.str() << std::endl;
56 #elif defined(VISP_HAVE_DC1394)
58 std::cout <<
"Use DC1394 grabber" << std::endl;
61 #elif defined(VISP_HAVE_CMU1394)
63 std::cout <<
"Use CMU1394 grabber" << std::endl;
66 #elif defined(VISP_HAVE_FLYCAPTURE)
68 std::cout <<
"Use FlyCapture grabber" << std::endl;
71 #elif defined(VISP_HAVE_REALSENSE2)
73 std::cout <<
"Use Realsense 2 grabber" << std::endl;
76 config.disable_stream(RS2_STREAM_DEPTH);
77 config.disable_stream(RS2_STREAM_INFRARED);
78 config.enable_stream(RS2_STREAM_COLOR, 640, 480, RS2_FORMAT_RGBA8, 30);
81 #elif ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI))|| ((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_VIDEOIO))
82 cv::VideoCapture g(opt_device);
84 std::cout <<
"Failed to open the camera" << std::endl;
92 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
107 bool init_done =
false;
109 bool germ_selected =
false;
114 #if defined(VISP_HAVE_V4L2) || defined(VISP_HAVE_DC1394) || defined(VISP_HAVE_CMU1394) || defined(VISP_HAVE_FLYCAPTURE) || defined(VISP_HAVE_REALSENSE2)
116 #elif ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI))|| ((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_VIDEOIO))
129 germ_selected =
true;
132 if (germ_selected && !init_done) {
134 std::cout <<
"Tracking initialized" << std::endl;
138 germ_selected =
false;
140 else if (init_done) {
149 std::cout <<
"Tracking failed: " << e.
getMessage() << std::endl;
154 #if (VISP_CXX_STANDARD < VISP_CXX_STANDARD_11)
155 if (display !=
nullptr) {
164 std::cout <<
"There are missing 3rd parties to run this tutorial" << std::endl;
Firewire cameras video capture based on CMU 1394 Digital Camera SDK.
void open(vpImage< unsigned char > &I)
Class for firewire ieee1394 video devices using libdc1394-2.x api.
void open(vpImage< unsigned char > &I)
Class that defines generic functionalities for display.
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)
static void displayText(const vpImage< unsigned char > &I, const vpImagePoint &ip, const std::string &s, const vpColor &color)
This tracker is meant to track a blob (connex pixels with same gray level) on a vpImage.
void track(const vpImage< unsigned char > &I, bool canMakeTheWindowGrow=true)
void setGraphics(bool activate)
void setGraphicsThickness(unsigned int thickness)
void initTracking(const vpImage< unsigned char > &I, unsigned int size=0)
error that can be emitted by ViSP classes.
const char * getMessage() const
void open(vpImage< unsigned char > &I)
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 ...
void acquire(vpImage< unsigned char > &grey, double *ts=nullptr)
bool open(const rs2::config &cfg=rs2::config())
Class that is a wrapper over the Video4Linux2 (V4L2) driver.
void open(vpImage< unsigned char > &I)
void setScale(unsigned scale=vpV4l2Grabber::DEFAULT_SCALE)
void setDevice(const std::string &devname)
std::shared_ptr< vpDisplay > createDisplay()
Return a smart pointer vpDisplay specialization if a GUI library is available or nullptr otherwise.
vpDisplay * allocateDisplay()
Return a newly allocated vpDisplay specialization if a GUI library is available or nullptr otherwise.