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

16#000

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

16#001

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

16#256

S_WATCHDOGTIMEOUT

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

16#7xx

All error codes

Function was not executed successfully. See also: 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 THEN
    // Export Code into String
    hr := F_VN_ExportSubContainer_String(ipDecodedCode, 0, sCodeAsString, 255, hr);
    // Use sCodeAsString
ELSIF SUCCEEDED(hr) THEN
    // Process partial results
ELSE
    // Error handling
END_IF

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

TCVN_CSS_ONLY_NOT_INVERTED

1.

-

TCVN_CSS_FIRST_NOT_INVERTED

1.

2.

TCVN_CSS_ONLY_INVERTED

-

1.

TCVN_CSS_FIRST_INVERTED

2.

1.

Mirroring

eSearchStrategy

Original image

Mirrored image

TCVN_CSS_ONLY_NOT_FLIPPED

1.

-

TCVN_CSS_FIRST_NOT_FLIPPED

1.

2.

TCVN_CSS_ONLY_FLIPPED

-

1.

TCVN_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 := TCVN_CSS_ONLY_FLIPPED + TCVN_CSS_FIRST_INVERTED;

The TCVN_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.