Document

The Anyline Document Module detects document outlines, validates the angles of the document to ensure it is not too skewed, validates the document ratio, determines the sharpness of the text and rectifies the document.

In the first step the preview frames are analyzed. Once a valid and sharp document is detected, a high resolution image is taken from the camera, analyzed, and, if valid and sharp, perspectively corrected and cropped to the document bounds.

OCR

The module does not perform the OCR step, but instead provides a high resolution, perspectively transformed and rectified, cropped document image, which is ensured to hold sharp text.

Landscape mode

As of version 3.11, the Document Module is limited to Portrait Mode

Examples

A couple of different examples can be found at Anyline Demos and Samples: Document.

Automatic Scanning Process

Preview Processing

In the first step, the Document Module processes the preview frames from the camera, and performs all the checks and detections listed in the next section.

If the quality criteria is fullfilled, a full picture is taken from the camera (also referred to as fullFrame throughout this documentation), and further processed.

Full Frame Processing

If the preview was successful, a full picture in the desired pictureResolution is taken, and all the checks and detections listed in the next section are performed on the full picture again.

If these are passed, the cropped and perspectively transformed image is returned as a result.

Checks & Transformations

The Document Module performs a couple of checks on the input image to ensure the quality of the result. It also performs transformations on the image, which results in a perspectively corrected and cropped output image, containing only the document.

Manual Trigger

New in version 3.17.

The SDK offers the ability to manually trigger a corner detection of the document in the image, and to manually trigger a perspective transformation, without the checks performed in Preview Processing and Full Frame Processing.

Outline Detection

The outline of the document is detected within the image. Therefore the contrast between the document and the background should be as high is possible.

Starting with version 3.8 of the SDK, you can set the desired document ratio(s) in your implementation. The detected documents are then limited to the ratios you provide (plus some deviation). Other ratios are considered incorrect.

One donkey ear is allowed in the document. If there is a donkey ear present, the sides of the document are interpolated to form a new corner for the cropped image.

Anyline SDK prior 3.8

In SDK versions before 3.8, the document ratio was limited to documents in the DIN A standard. Also, the donkey ears detection was not present.

Skew Detection

The Document Module checks if the document is not too skewed. This is performed by a check on the interior angles of the outline of the document. If the angle is too high, the Perspective Transformation & Crop is likely to ruin the Sharpness Detection of the document because of pixel interpolation.

Perspective Transformation & Crop

Once a valid outline is detected, the document is perspectively transformed. This results in the document being displayed as if the camera was placed directly above the document.

The image is cropped as well, leaving only the document bounding box in the image.

Sharpness Detection

The document is analysed for the text sharpness. Only sharp images are considered valid, since all the steps of the Document Module aim towards an OCR step in a later stage.

The sharpness detection is robust in the face of text contrast, which means that sharpness detection works on gray text as well as on black text on a white background.

Sharpness Detection and Perspective Transformation

If the required perspective transformation on the document image is too high (i.e. if the camera is not placed above the document), the sharpness of the resulting image cannot be guaranteed, as the pixels are interpolated during the perspective transformation.

Known Limitations

Android x86

3.8.0 Android x86

As of version 3.8.0, the Document Scanner does not work on x86 Android devices, and will report Document Not Sharp. This is due to a limitation in a 3rd party library. This was fixed in version 3.9.0

Cordova Android

3.8.0 Cordova Android Camera 2 API devices

As of version 3.8.0, the Document Scanner on Cordova Android does not support the Camera 2 API. This can be avoided with by adding app:api_2_enabled="false" to the scanView in the layout file. This was fixed in version 3.9.0.