F_VN_ReadBarcodeExp2
Detect and interpret a 1d barcode within the provided image. Can be canceled by Watchdog.
Syntax
Definition:
FUNCTION F_VN_ReadBarcodeExp2 : HRESULT
VAR_INPUT
ipSrcImage : ITcVnImage;
ipDecodedData : Reference To ITcVnContainer;
ipContours : Reference To ITcVnContainer;
eBarcodeType : UDINT;
nCodeNumber : DINT;
eSearchDirection : ETcVnBarcodeSearchDirection;
ipAngles : 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) |
ipContours |
Reference To ITcVnContainer |
Returns the code positions as contours (optional, set to 0 if not required; ContainerType_Vector_Vector_TcVnPoint2_DINT) |
eBarcodeType |
UDINT |
Types of barcode to search for (ETcVnBarcodeType) |
nCodeNumber |
DINT |
Number of 1d barcode that should be detected within the provided image (currently only 1 supported). |
eSearchDirection |
Barcode search direction. | |
ipAngles |
Reference To ITcVnContainer |
Returns the clockwise code rotation angles (optional, set to 0 if not required; ContainerType_Vector_REAL) |
hrPrev |
HRESULT indicating the result of previous operations (If SUCCEEDED(hrPrev) equals false, no operation is executed.) |
Further information
The function F_VN_ReadBarcodeExp
is the expert variant of F_VN_ReadBarcode. It contains additional parameters for returning the code position and for setting the search direction.
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.
Position of the code
The parameter ipContour
returns the code position that is found as a contour.
Number of codes
The parameter nCodeNumber
defines how many codes are to be searched for.
Search for more than one barcode not supported Searching for several barcodes in one image is currently not supported. The parameter nCodeNumber := 1 must therefore be set. |
Search direction
The search direction can be specified via eSearchDirection
:
- With
TCVN_BSD_ANY
, the search is first carried out in the horizontal direction and then in the vertical direction. - With
TCVN_BSD_HORIZONTAL
, the search is only carried out in a horizontal direction. - With
TCVN_BSD_VERTICAL
, the search is only carried out in the vertical direction.
Angle of rotation
The parameter ipAngles
returns the rotation angle of the codes found in a clockwise direction in 90° steps. The container is of the type ContainerType_Vector_REAL
. This parameter is optional and can be set to 0 if it is not required.
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 |