startDataCapture method
Opens a modal dialog with controls for the Data Capture scenario.
AbbyyRtrSdk.startDataCapture(callback, options)
Parameters
- callback
- The callback function which receives the data capture operation result. Your callback should expect a single JSON object as an argument (see Result).
- options
- JSON object specifying data capture parameters (see Options).
Options
The table below describes the JSON object that you can pass as the options argument to change data capture settings. All keys are optional. Omitting a key means that a default setting will be used, except the profile and customDataCaptureScenario keys: you must specify either one of them, but not both at the same time.
Key | Value type | Description |
---|---|---|
profile | string | The predefined data capture profile to use, for example: "BusinessCards". |
customDataCaptureScenario | object |
Custom data capture settings. This object has the following keys:
Note: For details, see the How to Capture a Custom Data Field guide in the ABBYY Mobile Capture SDK Developer's Guide. Note: Currently a custom data capture profile supports one recognized field only (fields must contain only 1 element). See below for an example of a custom data capture scenario definition. |
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". |
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:
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). |
recognitionLanguages | string |
Recognition languages to use. If any of defined languages is not supported for current profile, an error will occur. Default: ["English"]. |
An example of a custom data capture scenario definition in the options JSON.
{
...
customDataCaptureScenario : {
name : "Code",
description : "Alphanumeric code, for example: X6YZ64 32VPA zyy777.",
recognitionLanguages : ["English"],
fields : [ {
regEx : "([a-zA-Z]+[0-9]+|[0-9]+[a-zA-Z]+)[0-9a-zA-Z]*"
} ]
},
...
}
Result
This section describes the JSON object that represents data recognition results. The callback you implement should parse this object and show results to user.
Key | Value type | Description |
---|---|---|
dataScheme | object |
The data scheme which was applied during data capture. The value is an object which has two keys:
If you had defined a custom data capture scenario in options, both the id and name will be the same as the scenario name you specified. If you selected a predefined profile, the id and name are specified by the profile. If an error occurs during processing, the dataScheme key is not present in the result. |
dataFields | object array |
Recognized data fields. Each object in the array represents a separate data field. The data field objects have the following keys:
In the components array each element is an object with the following keys:
If an error occurs during processing, the dataFields key is not present in the result. |
resultInfo | object |
Additional information. This object has the following keys:
|
error | object |
Error details. This key is present only if an error occurs. The value is an object which has a single key:
|
Below is an example of a result JSON when data capture succeeds.
{
dataScheme : {
id : "Hello",
name : "Hello"
},
dataFields : [
{
id : "Hello",
name : "Hello",
text : "Hello world!",
"quadrangle": [
{
"x": 82,
"y": 567
},
{
"x": 82,
"y": 567
},
{
"x": 82,
"y": 567
},
{
"x": 82,
"y": 567
}
],
components : [
{
text : "Hello",
"quadrangle": [
{
"x": 100,
"y": 780
},
{
"x": 100,
"y": 600
},
{
"x": 350,
"y": 600
},
{
"x": 350,
"y": 780
}
],
"rect": {
"top": 515,
"bottom": 568,
"left": 82,
"right": 528
},
},
...
}
]
}
],
resultInfo : {
stabilityStatus : "Available",
userAction : "Manually Stopped",
frameSize : "720 1280"
}
}
On error, you will receive a JSON which does not contain recognized data but provides an error message.
{
error : {
description : "Something unexpected have happened."
}
resultInfo : {
stabilityStatus : "Tentative",
userAction : "Canceled",
frameSize : "720 1280"
}
}
3/2/2022 12:59:15 PM