1 #include <visp3/detection/vpDetectorDataMatrixCode.h>
4 #include <visp3/detection/vpDetectorQRCode.h>
6 #include <visp3/gui/vpDisplayFactory.h>
7 #include <visp3/io/vpImageIo.h>
9 int main(
int argc,
const char **argv)
12 #if (defined(VISP_HAVE_ZBAR) || defined(VISP_HAVE_DMTX)) && \
13 defined(VISP_HAVE_DISPLAY)
15 #ifdef ENABLE_VISP_NAMESPACE
18 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
19 std::shared_ptr<vpDisplay> display;
27 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
37 #if (defined(VISP_HAVE_ZBAR) && defined(VISP_HAVE_DMTX))
40 for (
int i = 1; i < argc; i++) {
41 if (std::string(argv[i]) ==
"--code-type" && i + 1 < argc) {
42 opt_barcode = atoi(argv[++i]);
44 else if (std::string(argv[i]) ==
"--help" || std::string(argv[i]) ==
"-h") {
45 std::cout <<
"Usage: " << argv[0] <<
" [--code-type <0 for QR code | 1 for DataMatrix code>] [--help] [-h]"
52 detector =
new vpDetectorQRCode;
56 #elif defined(VISP_HAVE_ZBAR)
57 detector =
new vpDetectorQRCode;
60 #elif defined(VISP_HAVE_DMTX)
69 bool status = detector->
detect(I);
71 std::ostringstream legend;
72 legend << detector->
getNbObjects() <<
" bar code detected";
80 std::vector<vpImagePoint> p = detector->
getPolygon(i);
88 for (
size_t j = 0; j < p.size(); j++) {
90 std::ostringstream number;
103 std::cout <<
"Catch an exception: " << e.
getMessage() << std::endl;
105 #if (VISP_CXX_STANDARD < VISP_CXX_STANDARD_11)
106 if (display !=
nullptr) {
static const vpColor blue
static const vpColor green
std::vector< std::vector< vpImagePoint > > & getPolygon()
vpRect getBBox(size_t i) const
size_t getNbObjects() const
std::vector< std::string > & getMessage()
virtual bool detect(const vpImage< unsigned char > &I)=0
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 displayCross(const vpImage< unsigned char > &I, const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1)
static void flush(const vpImage< unsigned char > &I)
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)
static void displayText(const vpImage< unsigned char > &I, const vpImagePoint &ip, const std::string &s, const vpColor &color)
error that can be emitted by ViSP classes.
const char * getMessage() const
static void read(vpImage< unsigned char > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND)
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
unsigned int getHeight() const
Defines a rectangle in the plane.
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.