startTextCapture method

Opens a modal dialog with controls for the Text Capture scenario.

AbbyyRtrSdk.startTextCapture(callback, options)

Parameters

callback
The callback function which receives the text capture operation result. Your callback should expect a single JSON object as an argument (see Result).
options
JSON object specifying text capture parameters (see Options).

Options

The table below describes the JSON object that you can pass as the options argument to change text capture settings. All keys are optional. Omitting a key means that a default setting will be used.

Key Value type Description
licenseFileName string

The name of the license file. This file must be located in the www/rtr_assets/ directory in your project.

Default: "AbbyyRtrSdk.license".

selectableRecognitionLanguages string array

Recognition languages which can be selected by the user, for example: ["English", "French", "German"]. Empty array disables language selection.

 Note: For the list of supported languages and their identifiers, see Specifications — Available Languages in the ABBYY Mobile Capture SDK Developer's Guide.

Default: [] (empty array, language selection disabled).

recognitionLanguages string array

Recognition language selected by default.

Default: ["English"].

areaOfInterest string

Width and height of the recognition area, separated by a whitespace — for example: "0.8 0.3". The area of interest is centered in the preview frame, its width and height are relative to the preview frame size and should be in the [0.0, 1.0] range.

Default: "0.8 0.3" (intended to capture a few lines of text in portrait mode).

orientation string

The type of image orientation. This key can be set to the following values:

  • "portrait"
  • "landscape"
  • "default" (the orientation will be detected automatically)

Default: "default".

stopWhenStable boolean

Whether to stop the plugin as soon as the result status is "Stable" (see Result status). When enabled (true), the recognition process can be stopped automatically. When disabled (false), recognition can be stopped only manually by user.

Default: true (automatic stop enabled).

isFlashlightVisible boolean

Show (true) or hide (false) the flashlight button in the text capture dialog.

Default: true (flashlight available).

isStopButtonVisible boolean

Show (true) or hide (false) the stop button in the text capture dialog. When the user taps stop, Mobile Capture SDK returns the latest recognition result.

Default: true (manual stop available).

Result

This section describes the JSON object that represents text recognition results. The callback you implement should parse this object and show results to user.

Key Value type Description
textLines object array

An array of objects representing recognized lines of text. These objects have the following keys:

  • text (string): the recognized text.
  • quadrangle (object): quadrangle containing text, represented by an array of its four vertices' coordinates: { x: int, y: int }. The vertices are indexed clockwise starting from the bottom left.
  • rect (object): bounding rectangle for quadrangle. The rectangle is set by the following parameters:
      • top (int): upper left point ordinate
      • bottom (int): bottom left point ordinate
      • left (int): upper left point abscissa
      • right (int): upper right point abscissa

    #ERROR_snippet# The rect key exists in the iOS version only.

If an error occurs during processing, the textLines key is not present in the result.

resultInfo object

Additional information. This object has the following keys:

  • stabilityStatus (string): result stability status. See Result status for details.
  • userAction (string): the user's action which stopped the plugin, if any. Can be "Manually Stopped" if the stop button has been used, and "Canceled" if the user canceled processing. If the plugin has stopped automatically, the userAction key is not present in resultInfo.
  • frameSize (string): full size of the preview frame, a string with 2 integers separated with a whitespace ("720 1280").
  • recognitionLanguages (string array): languages used for recognition, the array contains language identifiers (["English", "French", "German"]).
error object

Error details. This key is present only if an error occurs. The value is an object which has a single key:

  • description (string): human-readable error description.

Below is an example of a result JSON when text capture succeeds.

{
 textLines : [
   {
     text : "Welcome to ABBYY Mobile Capture SDK",
     "quadrangle": [
       {
        "x": 82,
        "y": 567
      },
       {
        "x": 82,
        "y": 567
      },
       {
        "x": 82,
        "y": 567
      },
       {
        "x": 82,
        "y": 567
      }
     ],
   "rect": {
    "top": 515,
    "bottom": 568,
    "left": 82,
    "right": 528
   },
   }  ],
 resultInfo : {
   stabilityStatus : "Available",
   userAction : "Manually Stopped",
   frameSize : "720 1280",
   recognitionLanguages : ["English", "French"]
 }
}

On error, you will receive a JSON which does not contain recognized text but provides an error message.

{
 error : {
   description : "Something has gone wrong."
 },
 resultInfo : {
   stabilityStatus : "Tentative",
   userAction : "Canceled",
   frameSize : "720 1280",
   recognitionLanguages : ["English", "French"]
 }
}

3/2/2022 12:59:15 PM

Usage of Cookies. In order to optimize the website functionality and improve your online experience ABBYY uses cookies. You agree to the usage of cookies when you continue using this site. Further details can be found in our Privacy Notice.