F_VN_GradeDataMatrixCodeExp
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. (expert function)
Syntax
Definition:
FUNCTION F_VN_GradeDataMatrixCodeExp : HRESULT
VAR_INPUT
ipSrcImage : ITcVnImage;
ipDecodedData : Reference To ITcVnContainer;
END_VAR
VAR_IN_OUT
stCodeGrades : TcVnCodeGradesDM;
END_VAR
VAR_INPUT
fModuleWidth : REAL;
ipResultVisualization : Reference To ITcVnImage;
ipMarginGrades : Reference To ITcVnContainer;
ipContour : Reference To ITcVnContainer;
hrPrev : HRESULT;
END_VAR
VAR_OUTPUT
fAngleDeg : REAL;
END_VAR
Inputs
Name |
Type |
Description |
---|---|---|
ipSrcImage |
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. |
ipResultVisualization |
Reference To ITcVnImage |
Returns a visualization of the scan grid (optional, set to 0 if not required). Module margin grades are color coded: >= 3 as green, >= 2 as light blue, >= 1 as orange, < 1 as red |
ipMarginGrades |
Reference To ITcVnContainer |
Returns the individual margin grade for each module, e.g. to create a custom visualization (optional, set to 0 if not required; ContainerType_Vector_TcVnVector3_REAL, containing [x-position, y-position, grade]) |
ipContour |
Reference To ITcVnContainer |
Returns the 4 code corner points, excluding the quiet zone (optional, set to 0 if not required; ContainerType_Vector_TcVnPoint2_DINT) |
hrPrev |
HRESULT indicating the result of previous operations (If SUCCEEDED(hrPrev) equals false, no operation is executed.) |
In/Outputs
Name |
Type |
Description |
---|---|---|
stCodeGrades |
Returns the code grades in the range from 0 (very bad) to 4 (very good) |
Outputs
Name |
Type |
Description |
---|---|---|
fAngleDeg |
REAL |
Returns the clockwise rotation angle in degree |
Further information
The function F_VN_GradeDataMatrixCodeExp
is an expert variant of F_VN_GradeDataMatrixCode. It contains additional parameters.
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);
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.
Presentation of results
ipResultVisualization
returns an image with the visualization of the scan grid and the respective evaluation results. The modules are color-coded according to the individual grades: >= 3
as green, >= 2
as light blue, >= 1
as orange, < 1
as red. This parameter is optional and can be set to 0 if it is not required.
Margin information
ipMarginGrades
returns additional information on the individual margin ratings of each module for a more detailed evaluation. The return vector of the type ContainerType_Vector_TcVnVector3_REAL
contains the X and Y position of the center points and the grade for each module. This parameter is optional and can be set to 0 if it is not required.
Position of the code
The parameter ipContour
returns the code corner points as four contour points of the type ContainerType_Vector_TcVnPoint2_DINT
. The corner points are at the edge of the outer modules. The contour can be drawn directly with F_VN_DrawContours, for example, or further analyzed with the Contour Analysis functions. This parameter is optional and can be set to 0 if it is not required.
Rotation angle (return value)
fAngleDeg
returns the clockwise rotation angle in degrees.
Application
The print quality of a Data Matrix Code can be determined in this way, for example:
hr := F_VN_GradeDataMatrixCodeExp(
ipSrcImage := ipSrcImage,
ipDecodedData := ipDecodedData,
stCodeGrades := stCodeGrades,
fModuleWidth := fModuleWidth,
ipResultVisualization := ipResultVisualization,
ipMarginGrades := ipMarginGrades,
ipContour := ipContour,
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 |