startImageCapture method

Opens a screen for the Image Capture scenario.

 Note: You can manage and localize UI string sources. See User interface string sources section for details.

async function startImageCapture(settings)

Parameters

settings
Object specifying image capture parameters (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 image capture settings. All parameters are optional. 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".

cameraResolution string

The resolution of the images captured from the camera preview. This parameter can be set to the following values:

  • "HD"
  • "FullHD"
  • "UHD_4K"

Default: "FullHD".

isFlashlightButtonVisible boolean

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

Default: true (flashlight visible).

isCaptureButtonVisible boolean

Show (true) or hide (false) the button for taking photo manually.

Default: true (button is visible).

isGalleryButtonVisible boolean

Show (true) or hide (false) the button for choosing an image from photo gallery.

Default: true (button is visible).

orientation string

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

  • "Portrait"
  • "Landscape"
  • "Default" (the orientation will be detected automatically)

Default: "Default".

isShowPreviewEnabled boolean

Show a preview of an image after capture (true) or show a camera view (false)

Default: false (camera view is shown).

requiredPageCount int

Total number of pages to be captured.

Set the page-limitation mode of the image capture as following:

  • 0 to allow unlimited image capture. The set of the result images can be saved or edited at any time;
  • a positive value to set the exact number of images that should be captured. Images saving is enabled only when this number of images are been captured.

Default: 0.

destination string

Captured image will be saved to corresponding file ("File") or returned as encode base64 image string ("Base64").

 Note: Image can be saved to Base64 only for requiredPageCount=1. Otherwise an exception will be thrown.

Default: "File".

exportType string

Captured image will be saved to this format. This parameter can be set to the following values:

  • "Jpg"
  • "Png"
  • "Pdf" (all images will be saved to one PDF file)

Default: "Jpg".

compressionLevel string

The uniform image compression scale for lossy formats. This parameter can be set to the following values:

  • "Low"
  • "Normal"
  • "High"
  • "ExtraHigh"

Default: "Low".

defaultImageSettings object

Custom image capture settings. This object has the following parameters:

  • aspectRatioMin (float): Lower limit of the document's aspect ratio.
    This property is used in pair with the aspectRatioMax, defining an interval of acceptable aspect ratio values of the document to be captured. Setting aspect ratio will help to improve boundary detection accuracy.
    If only aspectRatioMax is set, aspectRatioMin will be set to 1. Default: 0 (aspect ratio is not set).
  • aspectRatioMax (float): Upper limit of document's aspect ratio.
    This property is used in pair with the aspectRatioMin, defining an interval of acceptable aspect ratio values of the document to be captured. Setting aspect ratio will help to improve boundary detection accuracy.
    If only aspectRatioMin is set, aspectRatioMax will be set to infinity. Default: 0 (aspect ratio is not set).
  • imageFromGalleryMaxSize (int): Maximum available size of an image, loaded from the gallery. The size is defined as the length of the largest side of an image (in pixels). Default: 4096.
  • minimumDocumentToViewRatio (float): the minimum document area relative to the whole frame area, required for capture. If the document area is less than this ratio, the image will not be captured. The value can be from 0 to 1. Default: 0.15.
  • documentSize (string): expected size of the original document in millimeters. This parameter can be set to the following constant values:
    • "A4"
    • "BusinessCard"
    • "Letter"
    • "Any"
    • or defined as a string with 2 integers separated with an 'x' symbol: "100x100".

All parameters are optional.

Result

This section describes the object that represents image capture results. Returned parameters depend on the scenario.

Parameter Value type Description
images object array

Captured images. This parameter is returned only if the exportType is set to "Jpg" or "Png".
Each object in the array represents a single image with corresponding information. The image objects have the following parameters:

  • resultInfo (object): this object has the following parameters:
    • exportType (string): the format of the captured image.
    • imageSize (object): full size of the preview frame, an object with int parameters width and height.
    • uriPrefix (string): add this string to the beginning of the filePath or base64 parameter to get a URI. This parameter can be 'file://'  if the destination is 'File' and 'data:image/jpeg;base64,' or 'data:image/png;base64,' if the destination is 'Base64'.  
  • filePath (string): full path to the exported file. This parameter is present if the destination is 'File'.
  • base64 (string): the original image returned as base64 image string. This parameter is present if the destination parameter was set to "Base64".
pdfInfo object

This parameter is returned if the exportType is set to "Pdf". The value is an object which has the following parameters:

  • filePath (string): full path to the exported PDF file.
  • pagesCount (integer): number of pages in the exported PDF file. Normally fits the number of captured images.
resultInfo object

Additional information. This object has the following parameters:

  • userAction (string): the user's action which stopped the module, if any. Can be "Canceled" if the user canceled processing. If the module has stopped automatically, the userAction parameter is not present in resultInfo.
  • uriPrefix (string): add this string to the beginning of the filePath or base64 parameter to get a URI. This parameter can be 'file://'  if the destination is 'File' and 'data:image/jpeg;base64,' or 'data:image/png;base64,' if the destination is 'Base64'.  

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

{
   "images": [
       {
           "resultInfo": {
imageSize: {
                 width: 658,
                 height: 1187
}
              "exportType": "Jpg"
           },
           "filePath": "/data/user/0/com.abbyy.rtr.reactnative.sample/files/pages/page_334fd281-f472-4756-a4a0-d1f8d1857a0c.jpg"
       }
   ]
}

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.