F_VN_ReadQRCode

F_VN_ReadQRCode 1:

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

F_VN_ReadQRCode 2: Inputs

Name

Type

Description

ipSrcImage

ITcVnImage

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

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

F_VN_ReadQRCode 3: Return value

HRESULT

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

F_VN_ReadQRCode 4:

1.

F_VN_ReadQRCode 5:

Position markings

2.

F_VN_ReadQRCode 6:

Alignment mark

3.

F_VN_ReadQRCode 7:

Timing rows

4.

F_VN_ReadQRCode 8:

Version information

5.

F_VN_ReadQRCode 9:

Data format

6.

F_VN_ReadQRCode 10:

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.
The specified number of codes was found in the image.

16#001

S_FALSE

The function was executed successfully.
Fewer codes than indicated in the image were found.

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