Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

A simple, Pillow-friendly, wrapper around the tesseract-ocr API for Optical Image Recognition (OCR).

tesserocr integrates directly with Tesseract’s C++ API using Cython which allows for a simple Pythonic and easy-to-read source code. It enables real concurrent execution when used with Python’s threading module by releasing the GIL while processing an image in tesseract.

tesserocr is designed to be Pillow-friendly but can also be used with image files instead.

Requirements

Requires libtesseract (>=3.02) and libleptonica.

On Debian/Ubuntu:

$ apt-get install tesseract-ocr libtesseract-dev libleptonica-dev

Optionally requires Cython for building (otherwise the generated .cpp file is compiled) and Pillow to support PIL.Image objects.

Installation

$ python setup.py install

Usage

Initialize and re-use the tesseract API instance to score multiple images:

from tesserocr import PyTessBaseAPI

images = ['sample.jpg', 'sample2.jpg', 'sample3.jpg']

with PyTessBaseAPI() as api:
    for img in images:
        api.SetImageFile(img)
        print api.GetUTF8Text()
        print api.AllWordConfidences()
# api is automatically finalized when used in a with-statement (context manager).
# otherwise api.End() should be explicitly called when it's no longer needed.

PyTessBaseAPI exposes several tesseract API methods. Make sure you read their docstrings for more info.

Basic example using available helper functions:

import tesserocr
from PIL import Image

print tesserocr.tesseract_version()  # print tesseract-ocr version
print tesserocr.get_languages()  # prints tessdata path and list of available languages

image = Image.open('sample.jpg')
print tesserocr.image_to_text(image)  # print ocr text from image
# or
print tesserocr.file_to_text('sample.jpg')

image_to_text and file_to_text can be used with threading to concurrently process multiple images which is highly efficient.

Download files

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

Source Distribution

tesserocr-1.2.1rc2.tar.gz (57.8 kB view details)

Uploaded Source

File details

Details for the file tesserocr-1.2.1rc2.tar.gz.

File metadata

  • Download URL: tesserocr-1.2.1rc2.tar.gz
  • Upload date:
  • Size: 57.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for tesserocr-1.2.1rc2.tar.gz
Algorithm Hash digest
SHA256 a11152100583492c697edee5ae239d66d856ff42aa253704455781412305b347
MD5 9c1f57d72adf762d6cb4ff1cf4212bff
BLAKE2b-256 c43fee98bf1bd27fda8d2d2a4685cb8c27045cbb06f7dc22afdb50f71969f109

See more details on using hashes here.

Release history Release notifications | RSS feed

2.11.0

36 files

2.10.0

36 files

2.9.2

36 files

2.9.1

36 files

2.9.0

36 files

2.8.0

26 files

2.7.1

26 files

2.7.0

26 files

2.6.3

26 files

2.6.2

26 files

2.6.1

17 files

2.6.0

1 file

2.5.2

1 file

2.5.1

1 file

2.5.0

1 file

2.4.1

1 file

2.4.0

1 file

2.3.1

1 file

2.3.0

1 file

2.2.2

1 file

2.2.1

1 file

2.2.0

1 file

2.1.3

1 file

2.1.2

1 file

2.1.1

1 file

2.0.0

1 file

This release

1.2.1rc2 This release

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page