Common Vision Blox 15.1
Loading...
Searching...
No Matches
Code Reader

C++ .NET Python
Cvb::CodeReader Stemmer.Cvb.CodeReader cvb.code_reader

Barcode, Decoding 1D and 2D codes

The CVB Code Reader is a high speed and reliable tool for decoding of both 1D and 2D codes for demanding machine vision applications. The reader delivers high decoding reliability with an accuracy of up to 99.9995% and remains robust even under challenging conditions such as reflective surfaces or low ambient lighting, as well as codes that are partially damaged, distorted, or of low quality.

Supported Codes

The following codes are supported:

2D Codes:

  • Data Matrix
  • QR, Micro QR
  • PDF417, MicroPDF417

1D Barcodes:

  • EAN8, EAN13 (including composite variants)
  • UPC-A, UPC-E (including composite variants)
  • Code 128
  • Code 39
  • Code 93
  • Code 11
  • Interleaved 2 of 5.

Postal Codes:

  • USPS Intelligent Mail
  • Dutch Post (KIX)
  • RoyalMail 4-State Code
  • Australia Post

GS1 Family:

  • GS1 DataBar-14
  • GS1 DataBar Stacked
  • GS1 DataBar Limited
  • GS1 DataBar Expanded
  • GS1 DataBar Expanded Stacked

Pharma Codes:

  • Pharmacode
  • Code 32 (Italian Pharmacode).

How To Use the Code Reader

The CVB Code Reader can be integrated with minimal effort. Code examples are available in the respective Decoder class documentation for C++, .NET, and Python: Cvb::CodeReader::Decoder, Stemmer.Cvb.CodeReader.Decoder, and cvb.code_reader.Decoder

The typical decoding workflow consists of the following steps:

  1. Create an instance of the decoder class: Cvb::CodeReader::Decoder, Stemmer.Cvb.CodeReader.Decoder, or cvb.code_reader.Decoder.
  2. Retrieve the configuration object for the desired symbology via the decoder, enable and configure it. In C++ and Python, select the code type using the Cvb::CodeReader::Symbology or cvb.code_reader.Symbology enum. In .NET, use the corresponding configuration class from the Stemmer.Cvb.CodeReader.Config namespace.
  3. Load an image and start the decoding process.

Note, that multiple code types can be configured in parallel by retrieving and enabling multiple configuration objects:

#include <cvb/code_reader/code_reader.hpp>
// create a code reader
auto decoder = Decoder::Create();
// enable multiple codes
decoder.Config<Symbology::Code11>().Enable();
decoder.Config<Symbology::QR>().Enable();
decoder.Config<Symbology::DataMatrix>().Enable();
// ...

// create a code reader
var decoder = Decoder.Create();
// enable multiple codes
decoder.GetConfig<Code11>().SetEnabled(true);
decoder.GetConfig<QR>().SetEnabled(true);
decoder.GetConfig<DataMatrix>().SetEnabled(true);
// ...

import cvb
# create a code reader
# enable multiple codes
for symbology in (
cvb.code_reader.Symbology.Code11,
cvb.code_reader.Symbology.QR,
cvb.code_reader.Symbology.DataMatrix
# ...
):
decoder.config(symbology).enable()
cvb.code_reader.Decoder create()

Recommendations

General Limitations and Recommendations

To support reliable detection and decoding, please consider the following guidelines:

  • General Image Size: The maximum supported image resolution is officially specified as 8192 × 8192 pixels. In practice, larger images may still be processed successfully, depending on available system resources and image content. However, this is not guaranteed and may vary between environments.
  • 2D Codes: A module size of up to 20 pixels is recommended. In many cases, decoding may still succeed with slightly larger modules, but this cannot be guaranteed.
  • Direct Part Marking (DPM) Codes: For DPM applications, the maximum supported image size is 1280 × 1024 pixels. Exceeding this limit may lead to decoding failures.

Performance vs. Robustness

By default, the CVB Code Reader is optimized to offer a balanced trade-off between decoding performance and robustness. To adjust this balance according to application requirements, several configuration options are available. For instance, enhancing robustness may slow down decoding, while prioritizing speed can reduce reliability under challenging conditions. The following options can be used to fine-tune this behavior:

Value Description
0 Default. Provides the highest damage tolerance and supports low-contrast codes.
1 Faster search with reduced damage tolerance. Low-contrast codes can still be detected.
2 Faster search with further reduced damage tolerance. Intended for medium-contrast codes.
3 Fastest search. Has the same damage tolerance as level 2 and is intended for high-contrast codes only.

Higher values can improve decoding speed, but may reduce the tolerance against damaged or low-contrast codes.

API Type Time specification
C++ std::chrono::duration Duration, converted to milliseconds
.NET System.TimeSpan Duration, converted to milliseconds
Python int Milliseconds

The supported range is 0 to 60000 milliseconds. A value of 0 disables the time limit.

A lower time limit can reduce the processing time per image, but may also reduce the probability of successfully decoding difficult codes.

Value Description
false Disables fast Data Matrix search.
true Enables fast Data Matrix search.

This option applies to Data Matrix decoding only. It can improve decoding performance in suitable applications. Depending on the image quality and code characteristics, decoding robustness may be affected.

Fast Data Matrix search should only be enabled if Data Matrix is the only enabled symbology.

Additional performance-related options may also be available within the configuration class of each individual code type. These options provide further control to optimize decoding behavior according to the symbology and the specific application requirements.

Performance Configuration Examples

Code search speed

The code search speed can be configured through the decoder.

// Set the code search speed to level 2.
decoder->SetCodeSearchSpeed(2);

// Set the code search speed to level 2.
decoder.CodeSearchSpeed = CodeSearchSpeed.Speed2;

# Set the code search speed to level 2.
decoder.code_search_speed = 2

Higher values can improve decoding speed, but may reduce the tolerance against damaged or low-contrast codes.

Decode time limit

The decode time limit is specified when starting the decoding operation.

#include <chrono>
auto result = decoder->ExecuteFor(
image->Plane(0),
std::chrono::milliseconds(100));

using System;
var result = decoder.ExecuteFor(
image.Planes[0],
TimeSpan.FromMilliseconds(100));

results, status = decoder.execute_for(
image.planes[0],
100) # milliseconds

The time limit is specified in milliseconds in Python. In C++ and .NET, it is specified using a duration. If the time limit is reached, the returned status indicates whether decoding completed within the specified time limit.

Fast Data Matrix search

Fast Data Matrix search is configured through the Data Matrix configuration.

auto &dataMatrix =
decoder->Config<Cvb::CodeReader::Symbology::DataMatrix>();
dataMatrix.SetFastDataMatrixSearchEnabled(true);

var dataMatrix = decoder.GetConfig<DataMatrix>();
dataMatrix.IsFastDataMatrixSearchEnabled = true;

data_matrix = decoder.config(
cvb.code_reader.Symbology.DataMatrix)
data_matrix.is_fast_data_matrix_search_enabled = True

Fast Data Matrix search should only be enabled if Data Matrix is the only enabled symbology.

Examples

Example code can be found in the respective Decoder class documentation Cvb::CodeReader::Decoder (C++), Stemmer.Cvb.CodeReader.Decoder (.NET), and cvb.code_reader.Decoder (Python).

Additionally the CVB installation comes along with example programs under