Skip to main content

Straightening documents with the Android Document Scanner

The Document Enhancer can straighten scanned documents by removing paper deformations such as creases, curl, folds, and crinkles, and correcting perspective distortion.

It supports two straightening modes:

ModeDescription
NONECrops the document based on estimated perspective distortion. Very fast.
STRAIGHTENRemoves paper deformations in addition to perspective correction.

Document straightening is available across multiple integration points in the Scanbot SDK, allowing flexibility depending on your workflow.

You can use it:

  • As part of the Ready-to-Use (RTU) Document Scanner UI for automatic processing during capture
  • On individual scanned pages for manual or selective post-processing
  • Via the Document API for full programmatic control and custom pipelines

Usage in the RTU UI Document Scanner

The document straightening can be configured in the RTU UI Document Scanner.

By default, the captured document pages are automatically straightened. The result includes the straightening parameters applied to the page. When disabled, the cropped images are returned without straightening applied.

Set Document Straightening Parameters
loading...

Straightening a scanned page

A scanned page can be straightened directly for more control.

  • Straighten after capture
  • Re-process existing pages
  • Keep original and processed versions

This allows flexible integration into custom review and editing workflows.

Direct Document straightening on page
loading...

Straightening an image

You can also straighten an image directly using the DocumentEnhancer API, providing full control over the enhancement process.

Direct Document straightening on image
loading...

Configuration options

The DocumentStraighteningParameters class provides the following options:

ParameterTypeDefaultDescription
straighteningModeDocumentStraighteningModeSTRAIGHTENThe type of straightening to apply.
aspectRatiosAspectRatio[]EmptyExpected aspect ratios for the document. The closest matching ratio from the list is used.

Aspect ratios

By default, the aspect ratio of the straightened document is automatically determined from the detected document corners. If the document is significantly deformed, the estimated aspect ratio may be inaccurate.

In such cases, you can provide a list of expected aspect ratios to improve accuracy. Note that if you want to support both portrait and landscape orientations for a given paper format, you need to provide both aspect ratios (e.g., AspectRatio(21.0, 29.7) and AspectRatio(29.7, 21.0) for A4 paper).

Want to scan longer than one minute?

Generate a free trial license to test the Scanbot SDK thoroughly.

Get free trial license