Skip to content

find_textFindTextFindTextfind_textT_find_text🔗

Short description🔗

find_textFindTextFindTextfind_textT_find_text — Find text in an image.

Signature🔗

find_text( image Image, text_model TextModel, out text_result TextResultID )void FindText( const HObject& Image, const HTuple& TextModel, HTuple* TextResultID )static void HOperatorSet.FindText( HObject image, HTuple textModel, out HTuple textResultID )def find_text( image: HObject, text_model: HHandle ) -> HHandle

Herror T_find_text( const Hobject Image, const Htuple TextModel, Htuple* TextResultID )

void HTextResult::HTextResult( const HImage& Image, const HTextModel& TextModel )

public HTextResult( HImage image, HTextModel textModel )

HTextResult HImage::FindText( const HTextModel& TextModel ) const

HTextResult HTextModel::FindText( const HImage& Image ) const

void HTextResult::FindText( const HImage& Image, const HTextModel& TextModel )

HTextResult HImage.FindText( HTextModel textModel )

HTextResult HTextModel.FindText( HImage image )

void HTextResult.FindText( HImage image, HTextModel textModel )

Description🔗

find_textFindText finds text specified by the TextModeltextModeltext_model in the Imageimageimage and returns the result in TextResultIDtextResultIDtext_result_id. Specific results of TextResultIDtextResultIDtext_result_id can be obtained with get_text_resultGetTextResult and get_text_objectGetTextObject.

The text results in TextResultIDtextResultIDtext_result_id differ, depending on how Modemodemode was set when creating the TextModeltextModeltext_model with create_text_model_readerCreateTextModelReader.

For a text model with Modemodemode = 'auto'"auto" find_textFindText extracts and classifies text of arbitrary size within the Imageimageimage. It is possible to restrict the search to characters with specific attributes, see set_text_model_paramSetTextModelParam for details.

For a text model with Modemodemode = 'manual'"manual" reasonable parameters for the text model, including the expected character height and width, need to be set using set_text_model_paramSetTextModelParam. Furthermore, the Imageimageimage is preprocessed such that character like structures are enhanced. The resulting compensated image can be queried from TextResultIDtextResultIDtext_result_id if 'persistence'"persistence" was set to 'true'"true" in TextModeltextModeltext_model.

Both the text models with Modemodemode = 'auto'"auto" and Modemodemode = 'manual'"manual" apply various thresholds to the input image and segment character candidates based on region and gray value features. These candidates are further clustered to lines. Each line is individually completed and tested if it fulfills the constraints of a text line. Text models with Modemodemode set to 'auto'"auto" require a text line to consist of at least two characters, whereas text models with Modemodemode set to 'manual'"manual" require a text line to consist of at least three characters. In a further step, punctuations and separators are added if the correspondent parameters were set via set_text_model_paramSetTextModelParam. Finally, if TextModeltextModeltext_model contains 'text_line_structure'"text_line_structure" entries, the completed line is fitted to these structures.

find_textFindText finds text which is roughly horizontally aligned in Imageimageimage. text_line_orientationTextLineOrientation and rotate_imageRotateImage can be used to achieve this alignment.

Since memory is allocated for the text result during the call of find_textFindText and during the following operations, the text result should be freed explicitly by the operator clear_text_resultClearTextResult as soon as it is no longer used.

Execution information🔗

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Automatically parallelized on internal data level.

This operator returns a handle. Note that the state of an instance of this handle type may be changed by specific operators even though the handle is used as an input parameter by those operators.

This operator supports canceling timeouts and interrupts.

Parameters🔗

Imageimageimage (input_object) singlechannelimage → object (byte / uint2)HObject (byte / uint2)HImage (byte / uint2)HObject (byte / uint2)Hobject (byte / uint2)

Input image.

TextModeltextModeltext_model (input_control) text_model → (handle)HTuple (HHandle)HTextModel, HTuple (IntPtr)HHandleHtuple (handle)

Text model specifying the text to be segmented.

TextResultIDtextResultIDtext_result_id (output_control) text_result → (handle)HTuple (HHandle)HTextResult, HTuple (IntPtr)HHandleHtuple (handle)

Result of the segmentation.

Example🔗

(HDevelop)

read_image (Image, 'numbers_scale')
create_text_model_reader ('auto', 'Document_Rej.omc', TextModel)
* Optionally specify text properties
set_text_model_param (TextModel, 'min_char_height', 20)
find_text (Image, TextModel, TextResultID)
* Return character regions and corresponding classification results
get_text_object (Characters, TextResultID, 'all_lines')
get_text_result (TextResultID, 'class', Class)

Result🔗

If the parameters are valid, the operator find_textFindText returns the value 2 (H_MSG_TRUE). If necessary, an exception is raised.

Combinations with other operators🔗

Combinations

Possible predecessors

create_text_model_readerCreateTextModelReader, set_text_model_paramSetTextModelParam, text_line_orientationTextLineOrientation, text_line_slantTextLineSlant

Possible successors

get_text_resultGetTextResult, get_text_objectGetTextObject

Module🔗

OCR/OCV