Code Reading

This group contains functions for detecting and reading 1D and 2D codes.

Functions

1D codes

2D codes

Code requirements

In general, a module size of at least three pixels is required; more than three pixels are recommended for more stable results. The image should be sharp and have a high contrast. In addition, a code orientation of approx. 0° or 90° is recommended so that the code is parallel to an image axis.

Interpretation of the HRESULT

For the Code Reading functions the HRESULT return values are used as follows:

Code

Name

Description

0x000

S_OK

Function was successfully executed and all expected codes were found (at least one code for the standard functions and nCodeNumber for the expert functions).

0x001

S_FALSE

Function was successfully executed and all expected codes were found (at least one code for the standard functions and nCodeNumber for the expert functions).

0x256

S_WATCHDOGTIMEOUT

Function was aborted by the watchdog. Some Code Reading functions can return partial results (see individual function descriptions).

0x7xx

All error codes

Function was not executed successfully. See: ADS Return Codes

Therefore, the usual check with SUCCEEDED() is not sufficient to deduce a found code and thus existing data in ipDecodedData. The following query can be used for this purpose:

if (hr == S_OK)
{
    // Export Code into String
    hr = ExportSubContainer_String(hr, ipDecodedCode, 0, sCodeAsString, 255);
    // Use sCodeAsString
}
else if (SUCCEEDED(hr))
{
    // Process partial results
}
else
{
    // Error handling
}

Search strategies for 2D codes

For 2D codes the search algorithms are applied to different variants of the input image in order to recognize as many codes as possible. Both inversion and mirroring of the image are used to generate various variants. The decision as to which variant is tested is called the search strategy. So that you have greater control over the runtime of the functions, this search strategy can be configured. The enum ETcVn2dCodeSearchStrategy is available for this purpose. With this you can specify for each possible image transformation (inversion and mirroring) whether it is to be applied and whether the original image or the transformed image should be checked first for codes.

The function parameter eSearchStrategy defines precisely this search strategy for corresponding code reading expert functions. The tables below show the different combinations:

Inversion

eSearchStrategy

Original image

Inverted image

CSS_ONLY_NOT_INVERTED

1.

-

CSS_FIRST_NOT_INVERTED

1.

2.

CSS_ONLY_INVERTED

-

1.

CSS_FIRST_INVERTED

2.

1.

Mirroring

eSearchStrategy

Original image

Mirrored image

CSS_ONLY_NOT_FLIPPED

1.

-

CSS_FIRST_NOT_FLIPPED

1.

2.

CSS_ONLY_FLIPPED

-

1.

CSS_FIRST_FLIPPED

2.

1.

A search strategy can be defined for each type of transformation. The search strategies of the different search strategies can be linked as follows:

eSearchStrategy = CSS_ONLY_FLIPPED | CSS_FIRST_INVERTED;

The CSS_DEFAULT option can be used to select a default setting that varies depending on the code type.

Code Reading 1:

Linking of search strategies not possible

The linking of several search strategies for the same transformation type is not permissible. Only one strategy for inversion and one for mirroring can be linked to each other.