Common Vision Blox 15.0
Loading...
Searching...
No Matches
cvb_code_reader/CVBpy/CodeReading

This example program is located in your CVB installation under %CVB%Tutorial/cvb_code_reader/CVBpy/CodeReading.

code_reading.py:

# @brief Example, that demonstrates how to decode Data Matrix codes in an image.
import os
import cvb
# 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.
config.enable()
# Configure additional parameters (optional).
config.polarity = cvb.code_reader.Polarity.DarkOnLight
# Alternatively, the configuration can be performed in a more concise manner:
#decoder.config(cvb.code_reader.Symbology.DataMatrix).enable().polarity = cvb.code_reader.Polarity.DarkOnLight
# Load the image and decode.
image_file = os.path.join(cvb.install_path(), "tutorial", "CodeReader", "Images", "DataMat", "Surrounded.bmp")
image = cvb.Image.load(image_file)
results = decoder.execute(image.planes[0])
# Display results.
print(f"{len(results)} code(s) found.")
for result in results:
print(f"{result.data}")
cvb.Image load(str file_name)
cvb.code_reader.Decoder create()
str install_path()