F_VN_OCR

F_VN_OCR 1:

Detects and recognizes characters in a binary image (white characters on black background).

Syntax

Definition:

FUNCTION F_VN_OCR : HRESULT
VAR_INPUT
    ipSrcImage   : ITcVnImage;
    eModel       : ULINT;
    ipCharacters : Reference To ITcVnContainer;
    hrPrev       : HRESULT;
END_VAR

F_VN_OCR 2: Inputs

Name

Type

Description

ipSrcImage

ITcVnImage

Source image (USINT, 1 channel, binary)

eModel

ULINT

Selection of OCR model types (ETcVnOcrModelType)

ipCharacters

Reference To ITcVnContainer

Returns the recognized characters (ContainerType_Vector_String_SINT)

hrPrev

HRESULT

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

F_VN_OCR 3: Return value

HRESULT

Further information

The function F_VN_OCR detects and recognizes characters in a binary image and returns the recognized characters in a container.

Parameter

Input image

The input image that is transferred to ipSrcImage must be a 1-channel binary image. Only white characters on a black background are permitted.

Model

A model type of ETcVnOcrModelType, which is to be used in a function call to classify the characters, must be transferred to eModel. This function only supports the use of one model per function call.

To be able to use a model, it must first be initialized with the function block FB_VN_InitializeFunction.

Recognized characters

The recognized characters are returned via the reference ipCharacters.

Expert parameters

The expert variant F_VN_OCRExp contains additional parameters.

Application

For example, a call of the OCR function, with a model for recognizing numbers, with subsequent string export looks like this:

hr := F_VN_OCR(
    ipSrcImage   := ipBinaryImage,
    eModel       := TCVN_OMT_NUMBERS,
    ipCharacters := ipCharactersResults,
    hrPrev       := hr);

// Export character to string
hr := F_VN_ExportSubContainer_String(ipCharactersResults, 0, sText, 255, hr);

Required License

TC3 Vision OCR

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