Straightening documents with the Linux 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:
| Mode | Description |
|---|---|
NONE | Crops the document based on estimated perspective distortion. Very fast. |
STRAIGHTEN | Removes paper deformations in addition to perspective correction. |
Straightening an image
You can also straighten an image directly using the DocumentEnhancer API, providing full control over the enhancement process.
- Python
- Java
- NodeJS
- C
loading...
loading...
loading...
loading...
Configuration options
The DocumentStraighteningParameters class provides the following options:
- Python
- Java
- NodeJS
- C
| Parameter | Type | Default | Description |
|---|---|---|---|
straightening_mode | DocumentStraighteningMode | DocumentStraighteningMode.STRAIGHTEN | The type of straightening to apply. |
aspect_ratios | list[AspectRatio] | Empty | Expected aspect ratios for the document. The closest matching ratio from the list is used. |
| Parameter | Type | Default | Description |
|---|---|---|---|
straighteningMode | DocumentStraighteningMode | DocumentStraighteningMode.STRAIGHTEN | The type of straightening to apply. |
aspectRatios | List<AspectRatio> | Empty | Expected aspect ratios for the document. The closest matching ratio from the list is used. |
| Parameter | Type | Default | Description |
|---|---|---|---|
straighteningMode | DocumentStraighteningMode | "STRAIGHTEN" | The type of straightening to apply. |
aspectRatios | AspectRatio[] | Empty | Expected aspect ratios for the document. The closest matching ratio from the list is used. |
| Parameter | Type | Default | Description |
|---|---|---|---|
straighteningMode | scanbotsdk_document_straightening_mode_t | SCANBOTSDK_DOCUMENT_STRAIGHTENING_MODE_STRAIGHTEN | The type of straightening to apply. |
aspect_ratios | scanbotsdk_aspect_ratio_t** | Empty | Expected 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.
- Python
- Java
- NodeJS
- C
In such cases, you can provide a list of expected aspect ratios using params.aspect_ratios to improve accuracy. Note that if you want to support both portrait and landscape orientations for a given paper format, provide both aspect ratios, for example AspectRatio(width=21.0, height=29.7) and AspectRatio(width=29.7, height=21.0) for A4.
In such cases, you can provide a list of expected aspect ratios using params.setAspectRatios(...) to improve accuracy. Note that if you want to support both portrait and landscape orientations for a given paper format, provide both aspect ratios, for example new AspectRatio(21.0, 29.7) and new AspectRatio(29.7, 21.0) for A4.
In such cases, you can provide a list of expected aspect ratios using params.aspectRatios to improve accuracy. Note that if you want to support both portrait and landscape orientations for a given paper format, provide both aspect ratios, for example new AspectRatio({ width: 21.0, height: 29.7 }) and new AspectRatio({ width: 29.7, height: 21.0 }) for A4.
In such cases, you can provide a list of expected aspect ratios when creating scanbotsdk_document_straightening_parameters_t to improve accuracy. Note that if you want to support both portrait and landscape orientations for a given paper format, provide both aspect ratios, for example by creating scanbotsdk_aspect_ratio_t values for 21.0 x 29.7 and 29.7 x 21.0 for A4.
Want to scan longer than one minute?
Generate a free trial license to test the Scanbot SDK thoroughly.
Get free trial licenseScanbot SDK is part of the Apryse SDK product family
A mobile scan is just the start. With Apryse SDKs, you can expand mobile workflows into full cross‑platform document processing. Whether you need to edit PDFs, add secure digital signatures, or use a fast, customizable document viewer and editor, Apryse gives you the tools to build powerful features quickly.
Learn more
