DetectorQRCode

class DetectorQRCode(self)

Bases: DetectorBase

Base class for bar code detector. This class is a wrapper over libzbar available from http://zbar.sourceforge.net . Installation instructions are provided here https://visp.inria.fr/3rd_zbar .

The detect() function allows to detect multiple QR codes in an image. Once detected, for each QR code it is possible to retrieve the location of the corners using getPolygon() , the encoded message using getMessage() , the bounding box using getBBox() and the center of gravity using getCog() .

The following sample code shows how to use this class to detect QR codes in an image.

#include <visp3/detection/vpDetectorQRCode.h>
#include <visp3/io/vpImageIo.h>

int main()
{
#ifdef VISP_HAVE_ZBAR
  vpImage<unsigned char> I;
  vpImageIo::read(I, "bar-code.pgm");

  vpDetectorQRCode detector;

  bool status = detector.detect(I);
  if (status) {
    for(size_t i=0; i < detector.getNbObjects(); i++) {
      std::cout << "Bar code " << i << ":" << std::endl;
      std::vector<vpImagePoint> p = detector.getPolygon(i);
      for(size_t j=0; j < p.size(); j++)
        std::cout << "  Point " << j << ": " << p[j] << std::endl;
      std::cout << "  Message: \"" << detector.getMessage(i) << "\"" << std::endl;
    }
  }
#endif
}

The previous example may produce results like:

Bar code 0:
  Point 0: 48, 212
  Point 1: 57, 84
  Point 2: 188, 92
  Point 3: 183, 220
  Message: "qrcode 2"
Bar code 1:
  Point 0: 26, 550
  Point 1: 35, 409
  Point 2: 174, 414
  Point 3: 167, 555
  Message: "qrcode 1"

Other examples are also provided in tutorial-barcode-detector.cpp and tutorial-barcode-detector-live.cpp

Default constructor.

Methods

__init__

Default constructor.

detect

Detect QR codes in the image.

Inherited Methods

getCog

Return the center of gravity location of the ith object.

getPolygon

Overloaded function.

getBBox

Return the bounding box of the ith object.

getNbObjects

Return the number of objects that are detected.

getMessage

Overloaded function.

setTimeout

Set detector timeout in milli-seconds.

Operators

__doc__

__init__

Default constructor.

__module__

Attributes

__annotations__

__init__(self)

Default constructor.

detect(self, I: visp._visp.core.ImageGray) bool

Detect QR codes in the image. Return true if a code is detected, false otherwise.

Parameters:
I: visp._visp.core.ImageGray

Input image.

getBBox(self, i: int) visp._visp.core.Rect

Return the bounding box of the ith object.

getCog(self, i: int) visp._visp.core.ImagePoint

Return the center of gravity location of the ith object.

getMessage(*args, **kwargs)

Overloaded function.

  1. getMessage(self: visp._visp.detection.DetectorBase) -> list[str]

Returns the contained message of the ith object if there is one.

  1. getMessage(self: visp._visp.detection.DetectorBase, i: int) -> str

Returns the contained message of the ith object if there is one.

getNbObjects(self) int

Return the number of objects that are detected.

getPolygon(*args, **kwargs)

Overloaded function.

  1. getPolygon(self: visp._visp.detection.DetectorBase) -> list[list[visp._visp.core.ImagePoint]]

Returns object container box as a vector of points.

  1. getPolygon(self: visp._visp.detection.DetectorBase, i: int) -> list[visp._visp.core.ImagePoint]

Returns ith object container box as a vector of points.

setTimeout(self, timeout_ms: int) None

Set detector timeout in milli-seconds. When set to 0, there is no timeout.