Skip to main content

Python quick start for the Linux Document Scanner SDK

Build a lightweight document scanner in Python for Linux.

Create the project and install the Scanbot SDK​

1. Install Python and OpenCV​

sudo apt update
sudo apt install -y python3-venv python3-opencv

2. Create and activate a virtual environment​

python3 -m venv .env --system-site-packages
source .env/bin/activate
pip install --upgrade pip setuptools wheel

3. Install the Scanbot SDK​

Replace <SCANBOT_SDK_VERSION> with the version number you want to install.

export SCANBOT_SDK_VERSION=<SCANBOT_SDK_VERSION>
pip install https://github.com/doo/scanbot-sdk-example-linux/releases/download/standalone-sdk%2Fv${SCANBOT_SDK_VERSION}/scanbotsdk-${SCANBOT_SDK_VERSION}-py3-none-linux_aarch64.whl

4. Verify installation​

python -c "import scanbotsdk; print('scanbotsdk OK')"

Project layout​

Create a minimal project folder with a single entry-point script:

mkdir -p document-quickstart-python
touch document-quickstart-python/main.py

Initialize the Scanbot SDK​

Before using any feature of the Scanbot SDK, initialize the SDK with your license key.

import scanbotsdk
from scanbotsdk import LicenseStatus

SCANBOT_LICENSE_KEY = "<SCANBOTSDK-LICENSE-KEY>"

def initialize_sdk() -> None:
scanbotsdk.initialize(SCANBOT_LICENSE_KEY)
license_info = scanbotsdk.get_license_info()
print(f"License Status: {license_info.status}")
if license_info.status != LicenseStatus.OKAY:
raise SystemExit("Invalid or expired license. Exiting.")

Scan a document image​

The following snippet scans a document from an image.

scan document from ImageRef
loading...

Run​

python main.py /path/to/document_image.jpg

Get in touch​

If you need further information or are interested in licensing the Scanbot SDK, please get in touch with our solution experts.