ReadBarcodeRoi

Detect and interpret a 1d barcode within the provided image. For best performance, the code should be horizontally aligned and in the image center.

Syntax

Definition:

HRESULT ReadBarcodeRoi(
    HRESULT                     hrPrev,
    ITcVnImage*                 ipSrcImage,
    ITcVnContainer*&            ipDecodedData,
    ETcVnBarcodeType            eBarcodeType,
    float&                      fAngleDeg,
    ETcVnBarcodeSearchDirection eSearchDirection = BSD_ANY,
    ITcVnContainer**            pipContour = nullptr,
    LONG                        nMaxScans = 30
)

Parameters

Name

Type

Default

Description

hrPrev

HRESULT

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

ipSrcImage

ITcVnImage*

Source image (USINT, 1 channel)

ipDecodedData

ITcVnContainer*&

Returns the decoded data (ContainerType_String_SINT)

eBarcodeType

ETcVnBarcodeType

Type of the barcode (supported: CODE39, CODE128, EAN8, EAN13, ITF, UPCA, UPCE)

fAngleDeg

float&

Returns the approximate clockwise rotation angle in degree

eSearchDirection

ETcVnBarcodeSearchDirection

BSD_ANY

Barcode search direction (BSD_ANY first tries horizontal, then vertical)

pipContour

ITcVnContainer**

nullptr

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

LONG

30

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

 Return value

HRESULT

Further information

The F_VN_ReadBarcodeRoi function is optimized for the detection of a single barcode within a defined image area (ROI).

Algorithm

To do this, the function uses a customized algorithm that requires the code to be centered in the transferred image. The function first searches for horizontally aligned codes and then for vertically aligned codes in the image.

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

Rotation angle (Return value)

The fAngleDeg return value returns the clockwise rotation angle in 90° steps.

Expert parameters

The expert version F_VN_ReadBarcodeRoiExp contains additional parameters.

Required License

TC3 Vision Code Reading

System Requirements