F_VN_GradeQRCode
Grades a QR code 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_GradeQRCode : HRESULT
VAR_INPUT
ipSrcImage : ITcVnImage;
ipDecodedData : Reference To ITcVnContainer;
END_VAR
VAR_IN_OUT
stCodeGrades : TcVnCodeGradesQR;
END_VAR
VAR_INPUT
fModuleWidth : REAL;
hrPrev : HRESULT;
END_VAR
VAR_OUTPUT
fAngleDeg : REAL;
END_VAR
Inputs
Name |
Type |
Description |
---|---|---|
ipSrcImage |
Source image, only containing the QR 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 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 F_VN_GradeQRCode
function determines the print quality of QR 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);
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 TcVnCodeGradesQR 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. |
nFormatInfo | Evaluates the format information encoded around the finder pattern. |
nVersionInfo | Evaluates the version information contained in the code from version 7 onwards. |
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_GradeQRCodeExp contains additional parameters.
Application
The print quality of a QR code can be determined in this way, for example:
hr := F_VN_GradeQRCode(
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 |