F_VN_ReadBarcode

F_VN_ReadBarcode 1:

Detect and interpret a 1d barcode within the provided image. Can be canceled by Watchdog.

Syntax

Definition:

FUNCTION F_VN_ReadBarcode : HRESULT
VAR_INPUT
    ipSrcImage    : ITcVnImage;
    ipDecodedData : Reference To ITcVnContainer;
    eBarcodeType  : UDINT;
    hrPrev        : HRESULT;
END_VAR

F_VN_ReadBarcode 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)

eBarcodeType

UDINT

Types of barcode to search for (ETcVnBarcodeType)

hrPrev

HRESULT

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

F_VN_ReadBarcode 3: Return value

HRESULT

Further information

The function F_VN_ReadBarcode detects a barcode in the image and reads it.

Algorithm

The function first searches for horizontally aligned codes and then for vertically aligned codes in the image.

Parameter

Input image

The input image ipSrcImage must be a 1-channel or 3-channel image with the element type USINT (8-bit). 3-channel images will be interpreted as RGB and converted internally into grayscale images.

Read data

The data read from the code are returned as a string in the container ipDecodedData. The container is of the type ContainerType_Vector_String_SINT.

Barcode type

The parameter eBarcodeType defines the barcode types to be searched for in the image. All barcode types in the enum ETcVnBarcodeType are supported. It is possible to select more than one type. It is recommended to restrict the selection to the types actually occurring in the end application in order to improve the runtime.

eBarcodeType := TCVN_BT_EAN13 + TCVN_BT_CODE128;

Use TCVN_BT_ANY to search for all available barcode types.

Expert parameters

The expert version F_VN_ReadBarcodeExp contains additional parameters.

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);

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