F_VN_ReadBarcodeRoiExp
Detect and interpret a 1d barcode within the provided image. For best performance, the code should be horizontally aligned and in the image center. (expert function)
Syntax
Definition:
FUNCTION F_VN_ReadBarcodeRoiExp : HRESULT
VAR_INPUT
ipSrcImage : ITcVnImage;
ipDecodedData : Reference To ITcVnContainer;
eBarcodeType : ETcVnBarcodeType;
eSearchDirection : ETcVnBarcodeSearchDirection;
ipContour : Reference To ITcVnContainer;
nMaxScans : DINT;
hrPrev : HRESULT;
END_VAR
VAR_OUTPUT
fAngleDeg : REAL;
END_VAR
Inputs
Name |
Type |
Description |
---|---|---|
ipSrcImage |
Source image (USINT, 1 channel) | |
ipDecodedData |
Reference To ITcVnContainer |
Returns the decoded data (ContainerType_String_SINT) |
eBarcodeType |
Type of the barcode (supported: CODE39, CODE128, EAN8, EAN13, ITF, UPCA, UPCE) | |
eSearchDirection |
Barcode search direction (BSD_ANY first tries horizontal, then vertical) | |
ipContour |
Reference To ITcVnContainer |
Returns 4 approximate code corner points, including the quiet zone. The width is accurate, but the actual height is not measured for performance reasons. Instead, it is statically set to 10% of the width, centered around the scan line that was decoded. (optional, set to 0 if not required; ContainerType_Vector_TcVnPoint2_DINT) |
nMaxScans |
DINT |
Maximum number of scan lines that are evaluated to find the barcode. The scan always starts at the image center and then alternates up- and downwards with increasing distance, using steps of (ipSrcImage height / nMaxScans). |
hrPrev |
HRESULT indicating the result of previous operations (If SUCCEEDED(hrPrev) equals false, no operation is executed.) |
Outputs
Name |
Type |
Description |
---|---|---|
fAngleDeg |
REAL |
Returns the approximate clockwise rotation angle in degree |
Further information
The F_VN_ReadBarcodeRoiExp
function is the expert version of F_VN_ReadBarcodeRoi. It contains additional parameters.
Parameter
Input image
The ipSrcImage
input image must be an 1-channel image with USINT
element type (8 bits). The code must be aligned horizontally or vertically in the center of the image.
Read data
The data read from the code are returned as a string in the ipDecodedData
container. 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 F_VN_ExportContainer_String function.
hr := F_VN_ExportContainer_String(ipDecodedData, sText, nMaxLength, hr);
Barcode type
The eBarcodeType
parameter defines the barcode type to be read. Only one barcode type can be transferred per function call. The following barcode types from the ETcVnBarcodeType enum are supported:
TCVN_BT_CODE39
TCVN_BT_CODE128
TCVN_BT_EAN8
TCVN_BT_EAN13
TCVN_BT_ITF
TCVN_BT_UPCA
TCVN_BT_UPCE
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.
Position of the code
The ipContour
parameter returns the code corner points, including the quiet zone, as four contour points of the type ContainerType_Vector_TcVnPoint2_DINT
. The position is based on the first scan line that could be decoded. The height is set statically to 10% of the width and centered around the scan line. The contour can be drawn directly with F_VN_DrawContours, for example, or further analyzed with the Contour Analysis functions. This parameter is optional and can be set to 0 if it is not required.
Maximum number of scan lines
The maximum number of scan lines that are evaluated to find the barcode is defined with nMaxScans
. The scan always starts in the center of the image and then moves up and down in steps of ipSrcImage height / nMaxScans
as the distance increases.
Rotation angle (Return value)
The fAngleDeg
return value returns the clockwise rotation angle in 90° steps.
Related functions
Required License
TC3 Vision Code Reading