1 #include <visp3/core/vpConfig.h> 3 #include <visp3/gui/vpDisplayGDI.h> 4 #include <visp3/gui/vpDisplayOpenCV.h> 5 #include <visp3/gui/vpDisplayX.h> 6 #include <visp3/core/vpImageConvert.h> 7 #include <visp3/detection/vpDetectorDataMatrixCode.h> 8 #include <visp3/detection/vpDetectorQRCode.h> 9 #ifdef VISP_HAVE_MODULE_SENSOR 10 #include <visp3/sensor/vpV4l2Grabber.h> 13 int main(
int argc,
const char** argv)
15 #if (VISP_HAVE_OPENCV_VERSION >= 0x020100) && (defined(VISP_HAVE_ZBAR) || defined(VISP_HAVE_DMTX)) 19 for (
int i=0; i<argc; i++) {
20 if (std::string(argv[i]) ==
"--device")
21 opt_device = atoi(argv[i+1]);
22 else if (std::string(argv[i]) ==
"--code-type")
23 opt_barcode = atoi(argv[i+1]);
24 else if (std::string(argv[i]) ==
"--help") {
25 std::cout <<
"Usage: " << argv[0]
26 <<
" [--device <camera number>] [--code-type <0 for QRcode | 1 for DataMatrix>] [--help]" 31 std::cout <<
"Use device: " << opt_device << std::endl;
37 #if defined(VISP_HAVE_V4L2) 39 std::ostringstream device;
40 device <<
"/dev/video" << opt_device;
44 #elif defined(VISP_HAVE_OPENCV) 45 cv::VideoCapture cap(opt_device);
47 std::cout <<
"Failed to open the camera" << std::endl;
56 #if defined(VISP_HAVE_X11) 58 #elif defined(VISP_HAVE_GDI) 60 #elif defined(VISP_HAVE_OPENCV) 66 #if (defined(VISP_HAVE_ZBAR) && defined(VISP_HAVE_DMTX)) 71 #elif defined(VISP_HAVE_ZBAR) 74 #elif defined(VISP_HAVE_DMTX) 81 #if defined(VISP_HAVE_V4L2) 90 bool status = detector->
detect(I);
91 std::ostringstream legend;
92 legend << detector->
getNbObjects() <<
" bar code detected";
97 std::vector<vpImagePoint> p = detector->
getPolygon(i);
101 for(
size_t j=0; j < p.size(); j++) {
103 std::ostringstream number;
118 std::cout <<
"Catch an exception: " << e << std::endl;
void acquire(vpImage< unsigned char > &I)
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
Display for windows using GDI (available on any windows 32 platform).
static void displayText(const vpImage< unsigned char > &I, const vpImagePoint &ip, const std::string &s, const vpColor &color)
Define the X11 console to display images.
void setDevice(const std::string &devname)
error that can be emited by ViSP classes.
virtual bool detect(const vpImage< unsigned char > &I)=0
size_t getNbObjects() const
static const vpColor green
static void flush(const vpImage< unsigned char > &I)
std::vector< std::vector< vpImagePoint > > & getPolygon()
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
virtual void setTitle(const char *title)=0
virtual void displayRectangle(const vpImagePoint &topLeft, unsigned int width, unsigned int height, const vpColor &color, bool fill=false, unsigned int thickness=1)=0
void setScale(unsigned scale=vpV4l2Grabber::DEFAULT_SCALE)
Class for the Video4Linux2 video device.
std::string & getMessage(size_t i)
unsigned int getHeight() const
Defines a rectangle in the plane.
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 ...
vpRect getBBox(size_t i) const
static const vpColor blue