CVBpy 15.0

Class for decoding. More...

Public Member Functions

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

Properties

 all_2d_codes_enabled = property
 bool: Gets or sets the status whether all 2D codes are enabled.
 
 all_common_1d_codes_enabled = property
 bool: Gets or sets the status whether all common 1D codes are enabled.
 
 custom_performance = property
 int: Gets or sets the custom image processing method used to optimize decoding robustness and performance (see cvb.code_reader.CustomPerformance).
 
 detector_density = property
 int: Gets or sets the detector density to control the search aggressiveness for small codes.
 
 is_basic_inkjet_dpm_enabled = property
 bool: Gets or sets the status of the Basic Inkjet DPM (Direct Part Marking) code decoding feature.
 

Detailed Description

Class for decoding.

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

To decode an image containing a supported code, 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 code_reader.Symbology. All supported code types are enumerated in the enum class code_reader.Symbology.

After configuring the decoder, load an image containing the code(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 symbology.
config = decoder.config(cvb.code_reader.Symbology.DataMatrix)
# Enable decoding for the selected symbology and configure
# additional (optional) parameters.
config.enable().polarity = cvb.code_reader.Polarity.DarkOnLight
# Alternatively, the configuration can be performed in a more
# concise manner:
decoder.config(cvb.code_reader.Symbology.QR).enable().polarity =\
cvb.code_reader.Polarity.DarkOnLight
# Load the image and decode.
image = cvb.Image.load("your_image_with_code.bmp")
results = decoder.execute(image.planes[0])
# Display results.
print(f"{results.size()} code(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:2300
cvb.code_reader.Decoder create()
Creates and returns a new decoder object.
Definition __init__.py:182

Member Function Documentation

◆ config()

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

Retrieves the configuration object for a specific symbology.

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

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

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

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

Parameters

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

Returns

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

◆ create()

Creates and returns a new decoder object.

Returns

cvb.code_reader.Decoder Newly created decoder object.

◆ execute() [1/2]

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

Performs the decoding.

Parameters

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

Returns

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

◆ execute() [2/2]

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

Parameters

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

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

Returns

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

Property Documentation

◆ all_2d_codes_enabled

all_2d_codes_enabled = property
static

bool: Gets or sets the status whether all 2D codes are enabled.

True if all 2D codes are enabled, False otherwise.

◆ all_common_1d_codes_enabled

all_common_1d_codes_enabled = property
static

bool: Gets or sets the status whether all common 1D codes are enabled.

Enables Code128, Code39, UPCA, UPCE, EAN8, EAN13, Interleaved2of5, Code93, GS1DataBar codes. True if all common 1D codes are enabled, False otherwise.

◆ custom_performance

custom_performance = property
static

int: Gets or sets the custom image processing method used to optimize decoding robustness and performance (see cvb.code_reader.CustomPerformance).

The default setting is code_reader.CustomPerformance.None.

◆ detector_density

detector_density = property
static

int: Gets or sets the detector density to control the search aggressiveness for small codes.

Lower values increase the robustness when decoding small or poorly printed 2D codes, but may result in longer decoding times. Higher values reduce decoding time, but may decrease robustness for small codes. The default value is 3. Valid values range from 1 to 4 (inclusive).

◆ 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.