Skip to main content

Scanning a Document from an Image | React Native Document Scanner

Document Detection

ScanbotSDK.detectDocument(imageFileUri: string): Promise

The Scanbot SDK uses digital image processing algorithms to find rectangular, document like, polygons in a digital image. This function applies edge dectection and processes all image operations in a background thread. There will be no UI started. As input, a file URI of an image must be passed. The output contains the Detection Result as a string and on success the cropped and perspective corrected image as a new file as well as the detected polygon. If there was no document detected the result enum provides the exact reason (noisy background, too dark, etc). The input image file will not be modified.

Returns

Returns object with the following fields

  • documentImageFileUri - File URI of the detected and cropped/warped document image as JPEG ('file:///...'). May be null if detection was not successful.
  • polygon - Contains the detected polygon as an array. May be empty if detection was not successful.
  • detectionResult - The detection status:
/** Detection Status */
export type DetectionStatus =
/** An acceptable polygon was detected. */
| 'OK'
/** A polygon was detected, but its size is too small. */
| 'OK_BUT_TOO_SMALL'
/** A polygon was detected, but it has too much perspective distortion. */
| 'OK_BUT_BAD_ANGLES'
/** A polygon was detected, but its aspect ratio should be landscape/portrait but is portrait/landscape. */
| 'OK_BUT_BAD_ASPECT_RATIO'
/** No polygon detected at all. */
| 'ERROR_NOTHING_DETECTED'
/** No polygon detected, image too dark. */
| 'ERROR_TOO_DARK'
/** No polygon detected, image too noisy (background). */
| 'ERROR_TOO_NOISY';

Want to scan longer than one minute?

Generate your free "no-strings-attached" Trial License and properly test the Scanbot SDK.

Get your free Trial License

What do you think of this documentation?


On this page

Scroll to top