Zivid C++ API 2.18.0+1b44dbef-1
Zivid::Experimental::Toolbox::BarcodeDetector Class Reference

Class for enabling the detection of barcodes. More...

#include <Zivid/Experimental/Toolbox/Barcode.h>

Public Member Functions

ZIVID_CORE_EXPORT BarcodeDetector ()
 Constructor.
ZIVID_CORE_EXPORT Settings2D suggestSettings (Camera &camera) const
 Get 2D capture settings that are ideal for barcode reading with the given camera.
ZIVID_CORE_EXPORT std::vector< LinearBarcodeDetectionResultdetectLinearCodes (const Frame2D &frame2d) const
 Detect linear (1D) barcode candidate regions based on the result of a 2D capture.
ZIVID_CORE_EXPORT std::vector< std::optional< LinearBarcodeDecodingResult > > decodeLinearCodes (const std::vector< LinearBarcodeDetectionResult > &detectionResults, const LinearBarcodeFormatFilter &formatFilter=LinearBarcodeFormatFilter::all()) const
 Decode linear (1D) barcode candidate regions.
ZIVID_CORE_EXPORT std::vector< LinearBarcodeDecodingResultreadLinearCodes (const Frame2D &frame2d, const LinearBarcodeFormatFilter &formatFilter=LinearBarcodeFormatFilter::all()) const
 Detect and decode linear (1D) barcodes based on the result of a 2D capture.
ZIVID_CORE_EXPORT std::vector< MatrixBarcodeDecodingResultreadMatrixCodes (const Frame2D &frame2d, const MatrixBarcodeFormatFilter &formatFilter=MatrixBarcodeFormatFilter::all()) const
 Detect and decode matrix (2D) barcodes based on the result of a 2D capture.
ZIVID_CORE_EXPORT std::string toString () const
 Get string representation of the object.

Detailed Description

Class for enabling the detection of barcodes.

Constructing an instance of this class initializes the resources needed for efficient barcode detection. For repeated detection it is recommended to keep and re-use an instance of this class and not create a new one every time.

The recommended workflow for detecting barcodes with an instance of this class is:

  1. Call BarcodeDetector::suggestSettings once to get a suitable Settings2D for your camera. Alternatively, create or load your own Settings2D optimized for your use-case.
  2. Whenever you want to capture an image for barcode detection, call Camera::capture2D using the Settings2D. This will yield a Frame2D instance.
  3. Running the algorithm to detect and decode barcodes in the image can then be done immediately or later by passing the Frame2D to BarcodeDetector::readLinearCodes or BarcodeDetector::readMatrixCodes.

Constructor & Destructor Documentation

◆ BarcodeDetector()

ZIVID_CORE_EXPORT Zivid::Experimental::Toolbox::BarcodeDetector::BarcodeDetector ( )

Constructor.

Member Function Documentation

◆ decodeLinearCodes()

ZIVID_CORE_EXPORT std::vector< std::optional< LinearBarcodeDecodingResult > > Zivid::Experimental::Toolbox::BarcodeDetector::decodeLinearCodes ( const std::vector< LinearBarcodeDetectionResult > & detectionResults,
const LinearBarcodeFormatFilter & formatFilter = LinearBarcodeFormatFilter::all() ) const

Decode linear (1D) barcode candidate regions.

This function attempts to decode barcode candidates that were previously detected using BarcodeDetector::detectLinearCodes. The ordering of the returned decoding results matches the ordering of the input detection results. If a specific candidate failed to decode, the corresponding element in the returned sequence will be nullopt.

By default this function will attempt to detect and decode all supported barcode formats. Users can achieve increased detection speed and reliability by using the formatFilter argument to specify a subset of formats, for example LinearBarcodeFormat::ean13 | LinearBarcodeFormat::ean8.

Parameters
detectionResultsResults from a previous call to detectLinearCodes
formatFilterA filter defining which barcode formats to look for.
Returns
A sequence of optional LinearBarcodeDecodingResult (nullopt if decoding failed)

◆ detectLinearCodes()

ZIVID_CORE_EXPORT std::vector< LinearBarcodeDetectionResult > Zivid::Experimental::Toolbox::BarcodeDetector::detectLinearCodes ( const Frame2D & frame2d) const

Detect linear (1D) barcode candidate regions based on the result of a 2D capture.

This function detects potential barcode regions in the image but does not attempt to decode them. Since decoding has not yet been attempted, the list of regions returned are likely to contain some false positives (regions that look like barcodes but are not actually barcodes). Use BarcodeDetector::decodeLinearCodes to attempt to decode some or all candidate image regions.

Parameters
frame2dA Frame2D instance from a 2D or 2D+3D capture
Returns
A sequence of LinearBarcodeDetectionResult (one per detected barcode candidate)

◆ readLinearCodes()

ZIVID_CORE_EXPORT std::vector< LinearBarcodeDecodingResult > Zivid::Experimental::Toolbox::BarcodeDetector::readLinearCodes ( const Frame2D & frame2d,
const LinearBarcodeFormatFilter & formatFilter = LinearBarcodeFormatFilter::all() ) const

Detect and decode linear (1D) barcodes based on the result of a 2D capture.

By default this function will attempt to detect and decode all supported barcode formats. Users can achieve increased detection speed and reliability by using the formatFilter argument to specify a subset of formats, for example LinearBarcodeFormat::ean13 | LinearBarcodeFormat::ean8.

Parameters
frame2dA Frame2D instance from a 2D or 2D+3D capture
formatFilterA filter defining which barcode formats to look for.
Returns
A sequence of LinearBarcodeDecodingResult (one per successfully decoded barcode)

◆ readMatrixCodes()

ZIVID_CORE_EXPORT std::vector< MatrixBarcodeDecodingResult > Zivid::Experimental::Toolbox::BarcodeDetector::readMatrixCodes ( const Frame2D & frame2d,
const MatrixBarcodeFormatFilter & formatFilter = MatrixBarcodeFormatFilter::all() ) const

Detect and decode matrix (2D) barcodes based on the result of a 2D capture.

By default this function will attempt to detect and decode all supported barcode formats. Users can achieve increased detection speed and reliability by using the formatFilter argument to specify a subset of formats, for example MatrixBarcodeFormat::qrcode | MatrixBarcodeFormat::dataMatrix.

Parameters
frame2dA Frame2D instance from a 2D or 2D+3D capture
formatFilterA filter defining which barcode formats to look for.
Returns
A sequence of MatrixBarcodeDecodingResult (one per successfully decoded barcode)

◆ suggestSettings()

ZIVID_CORE_EXPORT Settings2D Zivid::Experimental::Toolbox::BarcodeDetector::suggestSettings ( Camera & camera) const

Get 2D capture settings that are ideal for barcode reading with the given camera.

Parameters
cameraThe camera to find barcode settings for.
Returns
A Settings2D instance

◆ toString()

ZIVID_CORE_EXPORT std::string Zivid::Experimental::Toolbox::BarcodeDetector::toString ( ) const

Get string representation of the object.

Returns
BarcodeDetector as a string

The documentation for this class was generated from the following file: