1 #include <visp/vpDisplayGDI.h>
3 #include <visp/vpDisplayOpenCV.h>
4 #include <visp/vpDisplayX.h>
5 #include <visp/vpImageConvert.h>
6 #include <visp/vpDetectorDataMatrixCode.h>
7 #include <visp/vpDetectorQRCode.h>
8 #include <visp/vpV4l2Grabber.h>
10 int main(
int argc,
const char** argv)
12 #if (VISP_HAVE_OPENCV_VERSION >= 0x020100) && (defined(VISP_HAVE_ZBAR) || defined(VISP_HAVE_DMTX))
16 for (
int i=0; i<argc; i++) {
17 if (std::string(argv[i]) ==
"--device")
18 opt_device = atoi(argv[i+1]);
19 else if (std::string(argv[i]) ==
"--code-type")
20 opt_barcode = atoi(argv[i+1]);
21 else if (std::string(argv[i]) ==
"--help") {
22 std::cout <<
"Usage: " << argv[0]
23 <<
" [--device <camera number>] [--code-type <0 for QRcode | 1 for DataMatrix>] [--help]"
28 std::cout <<
"Use device: " << opt_device << std::endl;
34 #if defined(VISP_HAVE_V4L2)
36 std::ostringstream device;
37 device <<
"/dev/video" << opt_device;
41 #elif defined(VISP_HAVE_OPENCV)
42 cv::VideoCapture cap(opt_device);
44 std::cout <<
"Failed to open the camera" << std::endl;
53 #if defined(VISP_HAVE_X11)
55 #elif defined(VISP_HAVE_GDI)
57 #elif defined(VISP_HAVE_OPENCV)
63 #if (defined(VISP_HAVE_ZBAR) && defined(VISP_HAVE_DMTX))
68 #elif defined(VISP_HAVE_ZBAR)
71 #elif defined(VISP_HAVE_DMTX)
78 #if defined(VISP_HAVE_V4L2)
87 bool status = detector->
detect(I);
88 std::ostringstream legend;
89 legend << detector->
getNbObjects() <<
" bar code detected";
94 std::vector<vpImagePoint> p = detector->
getPolygon(i);
98 for(
size_t j=0; j < p.size(); j++) {
100 std::ostringstream number;
115 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