Skip to main content

Tesserocr bindings

Project description


Crop, deskew, segment into regions / tables / lines / words, or recognize with tesserocr

image image image Docker Automated build


This offers OCR-D compliant workspace processors for (much of) the functionality of Tesseract via its Python API wrapper tesserocr . (Each processor is a step in the OCR-D functional model, and can be replaced with an alternative implementation. Data is represented within METS/PAGE.)

This includes image preprocessing (cropping, binarization, deskewing), layout analysis (region, table, line, word segmentation) and OCR proper. Most processors can operate on different levels of the PAGE hierarchy, depending on the workflow configuration. Image results are referenced (read and written) via AlternativeImage, text results via TextEquiv, deskewing via @orientation, cropping via Border and segmentation via Region / TextLine / Word elements with Coords/@points.


Required ubuntu packages:

  • Tesseract headers (libtesseract-dev)
  • Some Tesseract language models (tesseract-ocr-{eng,deu,frk,...} or script models (tesseract-ocr-script-{latn,frak,...})
  • Leptonica headers (libleptonica-dev)

From PyPI

This is the best option if you want to use the stable, released version.


ocrd_tesserocr requires Tesseract >= 4.1.0. The Tesseract packages bundled with Ubuntu < 19.10 are too old. If you are on Ubuntu 18.04 LTS, please enable Alexander Pozdnyakov PPA which has up-to-date builds of Tesseract and its dependencies:

sudo add-apt-repository ppa:alex-p/tesseract-ocr
sudo apt-get update

sudo apt-get install git python3 python3-pip libtesseract-dev libleptonica-dev tesseract-ocr-eng tesseract-ocr wget
pip install ocrd_tesserocr

With docker

This is the best option if you want to run the software in a container.

You need to have Docker

docker pull ocrd/tesserocr

To run with docker:

docker run -v path/to/workspaces:/data ocrd/tesserocr ocrd-tesserocrd-crop ...

From git

This is the best option if you want to change the source code or install the latest, unpublished changes.

We strongly recommend to use venv.

git clone
cd ocrd_tesserocr
sudo make deps-ubuntu # or manually with apt-get
make deps        # or pip install -r requirements
make install     # or pip install .


See docstrings and in the individual processors and ocrd-tool.json descriptions.

Available processors are:


make test

This downloads some test data from under repo/assets, and runs some basic test of the Python API as well as the CLIs.

Set PYTEST_ARGS="-s --verbose" to see log output (-s) and individual test results (--verbose).

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for ocrd-tesserocr, version 0.8.1
Filename, size File type Python version Upload date Hashes
Filename, size ocrd_tesserocr-0.8.1-py3-none-any.whl (45.4 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size ocrd_tesserocr-0.8.1.tar.gz (25.4 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page