recognizeText method
Starts text capture and recognition for a single image. Captured image will be processed according to the passed settings and recognized text will be returned with some technical information such as warnings, if any, and text orientation on the image.
export async function recognizeText(settings)
Parameters
- settings
- Object specifying parameters of the text capture scenario for a single image (see Options).
Return values
The method returns result depending on how the scenario finished (see Result).
Options
The table below describes parameters that you can pass as the settings argument to change text capture settings. Omitting a parameter means that a default setting will be used.
Parameter | Value type | Description |
---|---|---|
licenseFileName | string |
The name of the license file. This file must be located in the /assets/ directory in your project. Default: "MobileCapture.License". |
imageUri | string |
imageUri (string): Image source for the operation passed as URI. This parameter can be set to the following values:
Required parameter. |
areaOfInterest | object |
A rectangle specifying the area of interest in the coordinates, set by the following parameters:
I.e., {top: 100, bottom: 1000, left: 100, right: 1000} Note: All parameters should be defined to set the areaOfInterest parameter. If some of them are defined and some are not, an error occurs. Default: a rectangle, containing the whole image. |
isTextOrientationDetectionEnabled | boolean |
Enables or disables detection of the image orientation while preprocessing. If the property is set to true, the image top is detected and correct orientation can be used for image rotation. You can set this property to false for speeding the process up. Note: Disable the image detection only if you can be sure that the captured image has correct orientation. Otherwise the text on image will not be detected and recognized. The default value of this property is true (enabled). |
recognitionLanguages | string[] |
List of languages, supported for the text recognition, i.e. ['English', 'Russian']. See the full list of supported languages here. Default: ['English']. |
Result
This section describes the object that represents text capture results. Returned parameters depend on the captured and passed image.
Parameter | Value type | Description |
---|---|---|
orientation | int |
An angle on which the image was rotated to get normal orientation. Possible values are: 0, 90, 180, 270. |
warnings | string[] |
Warnings that occurred during processing, if any. |
text | string | The whole recognized text as a single string. Text lines are divided with "\n". Text blocks are divided with "\n\n". |
textBlocks | object[] | An array of text blocks. Each text block is represented as an array of textLines parameter. |
textBlocks.textLines | object[] |
An array of text lines. Each text line has the following parameters:
|
textBlocks.textLines.charInfo | object[] |
An array, which elements contain information concerning concrete recognized symbol. This object contains parameters, describing the symbol's place at an image, and its recognition confidence.
|
Example of a result JSON.
02.03.2022 12:59:15