Barcode Detection
Experimental API for detecting and decoding 1D (linear) and 2D (matrix) barcodes in a 2D image.
Resides in Zivid::Experimental::Toolbox and may change without prior notice.
%%{init: {'themeVariables': {'fontSize': '18px'}, 'flowchart': {'nodeSpacing': 30, 'rankSpacing': 35}}}%%
flowchart LR
ImageBGRA["Image<ColorBGRA>"]
detectOp(["detect()"])
decodeOp(["decode()"])
LinearBarcodeDetectionResult
LinearBarcodeDecodingResult["[LinearBarcodeDecodingResult]"]
ImageBGRA -.-> detectOp --> LinearBarcodeDetectionResult
LinearBarcodeDetectionResult --> decodeOp --> LinearBarcodeDecodingResult
classDef zividClass fill:#4A8FA4,stroke:#34323D,color:#FFFFFF
classDef api fill:#91D2C8,stroke:#4A8FA4,color:#000000
class ImageBGRA,LinearBarcodeDetectionResult,LinearBarcodeDecodingResult zividClass
class detectOp,decodeOp api
BarcodeDetector
Detects barcodes in a Image<ColorBGRA>.
Call detect() to obtain a LinearBarcodeDetectionResult, then decode() on the result to get the decoded barcode strings.
-
BarcodeDetectorclass
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:
Call BarcodeDetector::suggestSettings once to get a suitable Settings2D for your camera. Alternatively, create or load your own Settings2D optimized for your use-case.
Whenever you want to capture an image for barcode detection, call Camera::capture2D using the Settings2D. This will yield a Frame2D instance.
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.
Public Functions
-
BarcodeDetector()
Constructor.
-
Settings2DsuggestSettings(Camera& camera)const
Get 2D capture settings that are ideal for barcode reading with the given camera.
- パラメータ:
camera -- The camera to find barcode settings for.
- 戻り値:
A Settings2D instance
-
stdvectorLinearBarcodeDetectionResult detectLinearCodes( Frame2D&const 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.
- パラメータ:
frame2d -- A Frame2D instance from a 2D or 2D+3D capture
- 戻り値:
A sequence of LinearBarcodeDetectionResult (one per detected barcode candidate)
-
stdvectorstdoptionalLinearBarcodeDecodingResult>decodeLinearCodes( stdvectorLinearBarcodeDetectionResult detectionResultsconst::<>&, LinearBarcodeFormatFilter& LinearBarcodeFormatFilterall)const formatFilter=::()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
formatFilterargument to specify a subset of formats, for exampleLinearBarcodeFormat::ean13 | LinearBarcodeFormat::ean8.- パラメータ:
detectionResults -- Results from a previous call to detectLinearCodes
formatFilter -- A filter defining which barcode formats to look for.
- 戻り値:
A sequence of optional LinearBarcodeDecodingResult (nullopt if decoding failed)
-
stdvectorLinearBarcodeDecodingResult readLinearCodes( Frame2D&const frame2d, LinearBarcodeFormatFilter& LinearBarcodeFormatFilterall)const formatFilter=::()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
formatFilterargument to specify a subset of formats, for exampleLinearBarcodeFormat::ean13 | LinearBarcodeFormat::ean8.- パラメータ:
frame2d -- A Frame2D instance from a 2D or 2D+3D capture
formatFilter -- A filter defining which barcode formats to look for.
- 戻り値:
A sequence of LinearBarcodeDecodingResult (one per successfully decoded barcode)
-
stdvectorMatrixBarcodeDecodingResult readMatrixCodes( Frame2D&const frame2d, MatrixBarcodeFormatFilter& MatrixBarcodeFormatFilterall)const formatFilter=::()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
formatFilterargument to specify a subset of formats, for exampleMatrixBarcodeFormat::qrcode | MatrixBarcodeFormat::dataMatrix.- パラメータ:
frame2d -- A Frame2D instance from a 2D or 2D+3D capture
formatFilter -- A filter defining which barcode formats to look for.
- 戻り値:
A sequence of MatrixBarcodeDecodingResult (one per successfully decoded barcode)
-
stdstringtoString()const::
Get string representation of the object.
- 戻り値:
BarcodeDetector as a string
See Zivid::NET::Experimental::Toolbox::BarcodeDetector in the
C# API reference.
- classBarcodeDetector
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.
Initialization
Initialize BarcodeDetector.
- suggest_settings(:Cameracamera ) Settings2D
Get 2D capture settings that are ideal for barcode reading with the given camera.
- パラメータ:
camera -- The camera to suggest settings for.
- 戻り値:
A Settings2D instance with suggested settings for barcode reading.
- detect_linear_codes(:Frame2Dframe2d ) list
Detect linear (1D) barcode candidate regions based on the result of a 2D capture.
This method 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 decode_linear_codes to attempt to decode some or all candidate image regions.
- パラメータ:
frame2d -- A Frame2D instance containing the image to find barcode candidates in.
- 戻り値:
A list of LinearBarcodeDetectionResult instances (one per detected barcode candidate).
- decode_linear_codes(:listdetection_results , =format_filterNone) list
Decode linear (1D) barcode candidate regions.
This method attempts to decode barcode candidates that were previously detected using detect_linear_codes. 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 list will be None.
- パラメータ:
detection_results -- A list of LinearBarcodeDetectionResult instances from a previous call to detect_linear_codes.
format_filter -- An optional set of LinearBarcodeFormat values to filter the detection to only these formats. If None or an empty set is provided, all supported formats will be detected.
- 戻り値:
A list of optional LinearBarcodeDecodingResult instances (None if decoding failed for that candidate).
- read_linear_codes(:Frame2Dframe2d , =format_filterNone) list
Detect and decode linear (1D) barcodes based on the result of a 2D capture.
- パラメータ:
frame2d -- A Frame2D instance containing the image to find barcodes in.
format_filter -- An optional set of LinearBarcodeFormat values to filter the detection to only these formats. If None or an empty set is provided, all supported formats will be detected.
- 戻り値:
A list of LinearBarcodeDecodingResult instances containing the results of the detection.
- read_matrix_codes(:Frame2Dframe2d , =format_filterNone) list
Detect and decode matrix (2D) barcodes based on the result of a 2D capture.
- パラメータ:
frame2d -- A Frame2D instance containing the image to find barcodes in.
format_filter -- An optional set of MatrixBarcodeFormat values to filter the detection to only these formats. If None or an empty set is provided, all supported formats will be detected.
- 戻り値:
A list of MatrixBarcodeDecodingResult instances containing the results of the decoding.
LinearBarcodeDetectionResult
Result of a linear barcode detection.
Contains located barcode regions that can be passed to decode() to retrieve the decoded data.
-
LinearBarcodeDetectionResultclass
Information about an image region that is likely (but not guaranteed) to be a linear (1D) barcode.
Public Functions
-
PointXYcenterPosition()const
Get the location of the region in the 2D image.
- 戻り値:
2D coordinates as a PointXY
-
BoundingBoxboundingBox()const
Get the bounding box of the region in the 2D image.
- 戻り値:
Bounding box as a BoundingBox
-
stdstringtoString()const::
Get string representation of the object.
- 戻り値:
LinearBarcodeDetectionResult as a string
-
PointXYcenterPosition()const
See the C# API reference.
- classLinearBarcodeDetectionResult(impl)
Information about an image region that is likely (but not guaranteed) to be a linear (1D) barcode.
Initialization
Initialize LinearBarcodeDetectionResult wrapper.
This constructor is only used internally, and should not be called by the end-user.
- パラメータ:
impl -- Reference to internal/back-end instance.
- 例外:
TypeError -- If argument does not match the expected internal class.
LinearBarcodeDecodingResult
Decoded linear barcode — symbology, value, and position.
-
LinearBarcodeDecodingResultclass
Information about a decoded linear (1D) barcode.
Public Functions
-
stdstringcode()const::
Get the code encoded in the barcode.
- 戻り値:
Code as a string
-
LinearBarcodeFormatcodeFormat()const
Get the format of the code.
- 戻り値:
Format as a LinearBarcodeFormat enum value
-
PointXYcenterPosition()const
Get the location of the barcode in the 2D image.
- 戻り値:
2D coordinates as a PointXY
-
BoundingBoxboundingBox()const
Get the bounding box of the barcode in the 2D image.
- 戻り値:
Bounding box as a BoundingBox
-
stdstringtoString()const::
Get string representation of the object.
- 戻り値:
LinearBarcodeDecodingResult as a string
-
stdstringcode()const::
See the C# API reference.
- classLinearBarcodeDecodingResult(impl)
Information about a decoded linear (1D) barcode.
Initialization
Initialize LinearBarcodeDecodingResult wrapper.
This constructor is only used internally, and should not be called by the end-user.
- パラメータ:
impl -- Reference to internal/back-end instance.
- 例外:
TypeError -- If argument does not match the expected internal class.
MatrixBarcodeDecodingResult
Decoded 2D (matrix) barcode — symbology, value, and corner points.
-
MatrixBarcodeDecodingResultclass
Information about a detected matrix (2D) barcode.
Public Functions
-
stdstringcode()const::
Get the code encoded in the barcode.
- 戻り値:
Code as a string
-
MatrixBarcodeFormatcodeFormat()const
Get the format of the code.
- 戻り値:
Format as a MatrixBarcodeFormat enum value
-
PointXYcenterPosition()const
Get the location of the barcode in the 2D image.
- 戻り値:
2D coordinates as a PointXY
-
BoundingBoxboundingBox()const
Get the bounding box of the barcode in the 2D image.
- 戻り値:
Bounding box as a BoundingBox
-
stdstringtoString()const::
Get string representation of the object.
- 戻り値:
MatrixBarcodeDecodingResult as a string
-
stdstringcode()const::
See the C# API reference.
- classMatrixBarcodeDecodingResult(impl)
Information about a decoded matrix (2D) barcode.
Initialization
Initialize MatrixBarcodeDecodingResult wrapper.
This constructor is only used internally, and should not be called by the end-user.
- パラメータ:
impl -- Reference to internal/back-end instance.
- 例外:
TypeError -- If argument does not match the expected internal class.
See also