F_VN_ReadQRCode
Detect and interpret a QR code within the provided image. Can be canceled by Watchdog.
Syntax
Definition:
FUNCTION F_VN_ReadQRCode : HRESULT
VAR_INPUT
ipSrcImage : ITcVnImage;
ipDecodedData : Reference To ITcVnContainer;
hrPrev : HRESULT;
END_VAR
Inputs
Name |
Type |
Description |
---|---|---|
ipSrcImage |
Source image (USINT elements, 1 channel or 3 channel (3 channel input is expected to be RGB and internally converted to Gray)) | |
ipDecodedData |
Reference To ITcVnContainer |
Returns the decoded code (ContainerType_Vector_String_SINT) |
hrPrev |
HRESULT indicating the result of previous operations (If SUCCEEDED(hrPrev) equals false, no operation is executed.) |
Further information
The QR code (Quick-Response code) according to IEC 18004 is a 2D code, which is particularly common in Germany in the field of mobile tagging. Thanks to the option to encode Kanji/Kana characters, the QR code has also become established in the industry in Asia.
The F_VN_ReadQRCode function can recognize and decode this code type in the image. This is based on one code per image.
QR code structure
1. | Position markings | |
2. | Alignment mark | |
3. | Timing rows | |
4. | Version information | |
5. | Data format | |
6. | Data field | |
7. |
| Quiet zone, at least 4 cells wide |
Flaws / damage can prevent detection and decoding.
Code search
The function F_VN_ReadQRCode searches line by line for a QR code in the image from top left to bottom right.
Read data from container
If the code was successfully found and decoded, the code content is returned in the container ipDecodedData
and can be exported to a string using the function F_VN_ExportSubContainer_String.
hr := F_VN_ExportSubContainer_String( ipDecodedData, 0, sText, nMaxLength, hr);
HRESULT
Like all TwinCAT Vision API functions, this function also returns an HRESULT to indicate whether the execution was successful or not. In the event of success, a distinction can be made between the following success codes in the subsequent handling of the results. To distinguish between these cases, the HRESULT
variable can be compared directly with S_OK
or S_FALSE
.
Code | Name | Description |
---|---|---|
16#000 | S_OK | The function was executed successfully. |
16#001 | S_FALSE | The function was executed successfully. |
16#256 | S_WATCHDOGTIMEOUT | The function was aborted by the watchdog. |
Samples
Related functions
Required License
TC3 Vision Code Reading
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 |