1 #include <visp3/core/vpConfig.h> 3 #include <visp3/core/vpImageConvert.h> 4 #include <visp3/detection/vpDetectorDataMatrixCode.h> 5 #include <visp3/detection/vpDetectorQRCode.h> 6 #include <visp3/gui/vpDisplayGDI.h> 7 #include <visp3/gui/vpDisplayOpenCV.h> 8 #include <visp3/gui/vpDisplayX.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 | " 27 "1 for DataMatrix>] [--help]" 32 std::cout <<
"Use device: " << opt_device << std::endl;
38 #if defined(VISP_HAVE_V4L2) 40 std::ostringstream device;
41 device <<
"/dev/video" << opt_device;
45 #elif defined(VISP_HAVE_OPENCV) 46 cv::VideoCapture cap(opt_device);
47 if (!cap.isOpened()) {
48 std::cout <<
"Failed to open the camera" << std::endl;
57 #if defined(VISP_HAVE_X11) 59 #elif defined(VISP_HAVE_GDI) 61 #elif defined(VISP_HAVE_OPENCV) 67 #if (defined(VISP_HAVE_ZBAR) && defined(VISP_HAVE_DMTX)) 72 #elif defined(VISP_HAVE_ZBAR) 75 #elif defined(VISP_HAVE_DMTX) 82 #if defined(VISP_HAVE_V4L2) 91 bool status = detector->
detect(I);
92 std::ostringstream legend;
93 legend << detector->
getNbObjects() <<
" bar code detected";
98 std::vector<vpImagePoint> p = detector->
getPolygon(i);
103 for (
size_t j = 0; j < p.size(); j++) {
105 std::ostringstream number;
119 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)
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
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 ...
std::vector< std::string > & getMessage()
static void setTitle(const vpImage< unsigned char > &I, const std::string &windowtitle)
static const vpColor blue
std::vector< std::vector< vpImagePoint > > & getPolygon()