F_VN_GradeDataMatrixCode

F_VN_GradeDataMatrixCode 1:

Grades a Data Matrix code (ECC200) according to ISO / IEC 15415:2011. Requires uniform illumination, good focus and the image sensor plane parallel to the code plane to achieve meaningful results.

Syntax

Definition:

FUNCTION F_VN_GradeDataMatrixCode : HRESULT
VAR_INPUT
    ipSrcImage    : ITcVnImage;
    ipDecodedData : Reference To ITcVnContainer;
END_VAR
VAR_IN_OUT
    stCodeGrades  : TcVnCodeGradesDM;
END_VAR
VAR_INPUT
    fModuleWidth  : REAL;
    hrPrev        : HRESULT;
END_VAR
VAR_OUTPUT
    fAngleDeg     : REAL;
END_VAR

F_VN_GradeDataMatrixCode 2: Inputs

Name

Type

Description

ipSrcImage

ITcVnImage

Source image, only containing the Data Matrix code region (USINT, 1 channel, including quiet zone)

ipDecodedData

Reference To ITcVnContainer

Returns the decoded data (ContainerType_String_SINT)

fModuleWidth

REAL

Minimum module width of the code in the image (in pixels). Must be at least 3, preferably 5 - 8.

hrPrev

HRESULT

HRESULT indicating the result of previous operations (If SUCCEEDED(hrPrev) equals false, no operation is executed.)

F_VN_GradeDataMatrixCode 3: In/Outputs

Name

Type

Description

stCodeGrades

TcVnCodeGradesDM

Returns the code grades in the range from 0 (very bad) to 4 (very good)

F_VN_GradeDataMatrixCode 4: Outputs

Name

Type

Description

fAngleDeg

REAL

Returns the clockwise rotation angle in degree

F_VN_GradeDataMatrixCode 5: Return value

HRESULT

Further information

The function F_VN_GradeDataMatrixCode determines the print quality of ECC200 Data Matrix Codes in accordance with the ISO/IEC 15415:2011 standard.

Parameter

Input image

The input image ipSrcImage must be an 1-channel image with element type USINT (8 bits). The input image may only contain the code to be checked, including the corresponding quiet zones.

To achieve meaningful results, uniform illumination, not underexposed or overexposed, good focusing on the code plane and an image sensor plane aligned parallel to it are required. Furthermore, the image resolution must be high enough for the module size. For 2D codes, the smallest module should be covered with at least 5 pixels in order to achieve good results.

Read data

The data read from the code are returned as a string in the container ipDecodedData. The container is of the type ContainerType_String_SINT. Once the code has been successfully found and decoded, the content can be exported to a string using the function F_VN_ExportContainer_String.

hr := F_VN_ExportSubContainer_String(ipDecodedData, sText, nMaxLength, hr);
F_VN_GradeDataMatrixCode 6:

Different decoding results

Decoding with the respective reference algorithm can lead to deviating results. It is therefore possible that the code content can be read by other devices or functions, but the reference algorithm fails.

Return of the quality assessment

The return value stCodeGrades of type TcVnCodeGradesDM contains the determined individual results and an overall total result nOverall. The quality grades ranges from 0 (very poor) to 4 (very good).

Parameter

Description

nDecode

Evaluates whether the code could be decoded with the reference algorithm.

nSymbolContrast

Evaluates the global symbol contrast, i.e. the difference between the brightest and darkest value in the test area.

nModulation

Evaluates the uniformity of the dark or bright modules.

nReflectanceMargin

Evaluates how well each module can be correctly distinguished as bright or dark compared to the global threshold.

nFixedPatternDamage

Evaluates the various fixed code components such as the finder or alignment pattern.

nAxialNonuniformity

Evaluates the uniform scaling of the code.

nGridNonuniformity

Evaluates deviations of the code grid.

nUnusedErrorCorrection

Evaluates the remaining capacity of the error correction.

nOverall

The overall grade of the code is the lowest grade achieved in the individual examinations.

Minimum module width

The expected minimum module width of the code in pixels is specified with fModuleWidth. If the module size in the image differs significantly from this, this can lead to inaccurate or no results and increased computing time.

Rotation angle (return value)

fAngleDeg returns the clockwise rotation angle in degrees.

Expert parameters

The expert variant F_VN_GradeDataMatrixCodeExp contains additional parameters.

Application

The print quality of a Data Matrix Code can be determined in this way, for example:

hr := F_VN_GradeDataMatrixCode(
    ipSrcImage       := ipSrcImage,
    ipDecodedData    := ipDecodedData,
    stCodeGrades     := stCodeGrades,
    fModuleWidth     := fModuleWidth,
    hrPrev           := hr,
    fAngleDeg        => fAngleDeg);

Required License

TC3 Vision Code Quality

System Requirements

Development environment

Target platform

PLC libraries to include

TwinCAT V3.1.4024.54 or later

PC or CX (x64) with PL50, e.g. Intel 4-core Atom CPU

Tc3_Vision