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;
vpRect getBBox(size_t i) const
void acquire(vpImage< unsigned char > &I)
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
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)
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
void setDevice(const std::string &devname)
error that can be emited by ViSP classes.
size_t getNbObjects() const
virtual bool detect(const vpImage< unsigned char > &I)=0
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. Thus to enable this class OpenC...
static void displayRectangle(const vpImage< unsigned char > &I, const vpImagePoint &topLeft, unsigned int width, unsigned int height, const vpColor &color, bool fill=false, unsigned int thickness=1)
void setScale(unsigned scale=vpV4l2Grabber::DEFAULT_SCALE)
static void displayCross(const vpImage< unsigned char > &I, const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1)
Class that is a wrapper over the Video4Linux2 (V4L2) driver.
unsigned int getHeight() const
std::string & getMessage(size_t i)
Defines a rectangle in the plane.
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
static void setTitle(const vpImage< unsigned char > &I, const std::string &windowtitle)
static const vpColor blue