CVBpy 15.0
Decoder Class Reference

Class for barcode decoding. More...

Inherits object.

Public Member Functions

Union[cvb.barcode.DataMatrixconfig (self, int symbology)
 Retrieves the configuration object for a specific barcode symbology. More...
 
cvb.barcode.Decoder create ()
 Creates and returns a new decoder object. More...
 
List[cvb.barcode.Resultexecute (self, cvb.ImagePlane plane)
 Performs the barcode decoding. More...
 
List[cvb.barcode.Resultexecute (self, cvb.ImagePlane plane, cvb.Rect aoi)
 

Properties

 is_basic_inkjet_dpm_enabled = property
 bool: Gets or sets the status of the Basic Inkjet DPM (Direct Part Marking) code decoding feature. More...
 

Detailed Description

Class for barcode decoding.

This class provides the core functionality for detecting and decoding barcodes in images. Each barcode type can be configured using its corresponding configuration class.

To decode an image containing a supported barcode, start by creating a decoder. You can configure your decoder using the member function Decoder.config(), which returns a reference to the desired configuration class. The configuration class is specified by the barcode.Symbology. All supported barcode types are enumerated in the enum class Barcode.Symbology.

After configuring the decoder, load an image containing the barcode(s) and execute the decoding process. The following code snippet demonstrates how to decode an image containing Data Matrix and QR codes:

# Create a decoder.
# Retrieve the configuration object for a specific barcode symbology.
config = decoder.config(cvb.barcode.Symbology.DataMatrix)
# Enable decoding for the selected symbology and configure
# additional (optional) parameters.
config.enable().polarity = cvb.barcode.Polarity.DarkOnLight
# Alternatively, the configuration can be performed in a more
# concise manner:
decoder.config(cvb.barcode.Symbology.QR).enable().polarity =\
cvb.barcode.Polarity.DarkOnLight
# Load the image and decode.
image = cvb.Image.load("your_image_with_barcode.bmp")
results = decoder.execute(image.planes[0])
# Display results.
print(f"{results.size()} barcode(s) found.")
for result in results:
print(f"{result.data}")
cvb.Image load(str file_name)
Loads an image with the given file name.
Definition: __init__.py:2309
cvb.barcode.Decoder create()
Creates and returns a new decoder object.
Definition: __init__.py:142

Member Function Documentation

◆ config()

Union[cvb.barcode.DataMatrix] config (   self,
int  symbology 
)

Retrieves the configuration object for a specific barcode symbology.

After creating a decoder, you can obtain the desired configuration object as shown below:

config = decoder.config(cvb.barcode.Symbology.DataMatrix)
config.enable()

Alternatively, you can utilize the fluent interface pattern for seamless configuration:

decoder.config(cvb.barcode.Symbology.DataMatrix).\
enable().mirroring = True

Parameters

symbology : int The barcode symbology for which the configuration is retrieved (see cvb.barcode.Symbology).

Returns

Union[cvb.barcode.DataMatrix] A reference to the configuration object corresponding to the specified symbology.

◆ create()

cvb.barcode.Decoder create ( )

Creates and returns a new decoder object.

Returns

cvb.barcode.Decoder Newly created decoder object.

◆ execute() [1/2]

List[cvb.barcode.Result] execute (   self,
cvb.ImagePlane  plane 
)

Performs the barcode decoding.

Parameters

plane : cvb.ImagePlane The image plane containing the barcode(s) to decode.

Returns

List[cvb.barcode.Result] A list of result objects containing the decoded barcode data.

◆ execute() [2/2]

List[cvb.barcode.Result] execute (   self,
cvb.ImagePlane  plane,
cvb.Rect  aoi 
)

Parameters

plane : cvb.ImagePlane The image plane containing the barcode(s) to decode.

aoi : cvb.Rect The area of interest within the image where the decoding operation will be performed.

Returns

List[cvb.barcode.Result] A list of result objects containing the decoded barcode data.

Property Documentation

◆ is_basic_inkjet_dpm_enabled

is_basic_inkjet_dpm_enabled = property
static

bool: Gets or sets the status of the Basic Inkjet DPM (Direct Part Marking) code decoding feature.

True if the decoding feature is enabled, False otherwise. This setting applies exclusively to DPM codes. Enabling Basic Inkjet DPM allows for the reading of low-quality inkjet images.