tesseract Documentation

Tesseract Open Source OCR Engine (main repository)

RAW Doc

1. Project Overview & Quickstart (tesseract-ocr/tesseract)

File: README.md

Tesseract OCR






Table of Contents

About

This package contains an OCR engine - libtesseract and a command line program - tesseract.

Tesseract 4 adds a new neural net (LSTM) based OCR engine which is focused on line recognition, but also still supports the legacy Tesseract OCR engine of Tesseract 3 which works by recognizing character patterns. Compatibility with Tesseract 3 is enabled by using the Legacy OCR Engine mode (--oem 0).
It also needs traineddata files which support the legacy engine, for example those from the tessdata repository.

Stefan Weil is the current lead developer. Ray Smith was the lead developer until 2017. The maintainer is Zdenko Podobny. For a list of contributors see AUTHORS
and GitHub's log of contributors.

Tesseract has unicode (UTF-8) support, and can recognize more than 100 languages "out of the box".

Tesseract supports various image formats including PNG, JPEG and TIFF.

Tesseract supports various output formats: plain text, hOCR (HTML), PDF, invisible-text-only PDF, TSV, ALTO and PAGE.

You should note that in many cases, in order to get better OCR results, you'll need to improve the quality of the image you are giving Tesseract.

This project does not include a GUI application. If you need one, please see the 3rdParty documentation.

Tesseract can be trained to recognize other languages.
See Tesseract Training for more information.

Brief history

Tesseract was originally developed at Hewlett-Packard Laboratories Bristol UK and at Hewlett-Packard Co, Greeley Colorado USA between 1985 and 1994, with some more changes made in 1996 to port to Windows, and some C++izing in 1998. In 2005 Tesseract was open sourced by HP. From 2006 until August 2017 it was developed by Google.

Major version 5 is the current stable version and started with release
5.0.0 on November 30, 2021. Newer minor versions and bugfix versions are available from
GitHub.

Latest source code is available from main branch on GitHub.
Open issues can be found in issue tracker,
and planning documentation.

See Release Notes
and Change Log for more details of the releases.

Installing Tesseract

You can either Install Tesseract via pre-built binary package
or build it from source.

Before building Tesseract from source, please check that your system has a compiler which is one of the supported compilers.

Running Tesseract

Basic command line usage:

text
tesseract imagename outputbase [-l lang] [--oem ocrenginemode] [--psm pagesegmode] [configfiles...]

For more information about the various command line options use tesseract --help or man tesseract.

Examples can be found in the documentation.

For developers

Developers can use libtesseract C or
C++ API to build their own application. If you need bindings to libtesseract for other programming languages, please see the
wrapper section in the AddOns documentation.

Documentation of Tesseract generated from source code by doxygen can be found on tesseract-ocr.github.io.

Support

Before you submit an issue, please review the guidelines for this repository.

For support, first read the documentation,
particularly the FAQ to see if your problem is addressed there.
If not, search the Tesseract user forum, the Tesseract developer forum and past issues, and if you still can't find what you need, ask for support in the mailing-lists.

Mailing-lists:

Please report an issue only for a bug, not for asking questions.

License

text
The code in this repository is licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

NOTE: This software depends on other packages that may be licensed under different open source licenses.

Tesseract uses the Leptonica library which essentially
uses a BSD 2-clause license.

Dependencies

Tesseract uses Leptonica library
for opening input images (e.g. not documents like pdf).
It is suggested to use leptonica with built-in support for zlib,
png and
tiff (for multipage tiff).

Latest Version of README

For the latest online version of the README.md see:

https://github.com/tesseract-ocr/tesseract/blob/main/README.md


File: unittest/README.md

Unit Testing for Tesseract

Requirements

Files and structure

text
β”œβ”€β”€ langdata_lstm
β”‚Β Β  β”œβ”€β”€ common.punc
β”‚Β Β  β”œβ”€β”€ common.unicharambigs
β”‚Β Β  β”œβ”€β”€ desired_bigrams.txt
β”‚Β Β  β”œβ”€β”€ eng
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ desired_characters
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ eng.config
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ eng.numbers
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ eng.punc
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ eng.singles_text
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ eng.training_text
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ eng.unicharambigs
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ eng.wordlist
β”‚Β Β  β”‚Β Β  └── okfonts.txt
β”‚Β Β  β”œβ”€β”€ extended
β”‚Β Β  β”‚Β Β  └── extended.config
β”‚Β Β  β”œβ”€β”€ extendedhin
β”‚Β Β  β”‚Β Β  └── extendedhin.config
β”‚Β Β  β”œβ”€β”€ font_properties
β”‚Β Β  β”œβ”€β”€ forbidden_characters_default
β”‚Β Β  β”œβ”€β”€ hin
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ hin.config
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ hin.numbers
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ hin.punc
β”‚Β Β  β”‚Β Β  └── hin.wordlist
β”‚Β Β  β”œβ”€β”€ kan
β”‚Β Β  β”‚Β Β  └── kan.config
β”‚Β Β  β”œβ”€β”€ kor
β”‚Β Β  β”‚Β Β  └── kor.config
β”‚Β Β  β”œβ”€β”€ osd
β”‚Β Β  β”‚Β Β  └── osd.unicharset
β”‚Β Β  └── radical-stroke.txt
β”œβ”€β”€ tessdata
β”‚Β Β  β”œβ”€β”€ ara.traineddata
β”‚Β Β  β”œβ”€β”€ chi_tra.traineddata
β”‚Β Β  β”œβ”€β”€ eng.traineddata
β”‚Β Β  β”œβ”€β”€ heb.traineddata
β”‚Β Β  β”œβ”€β”€ hin.traineddata
β”‚Β Β  β”œβ”€β”€ jpn.traineddata
β”‚Β Β  β”œβ”€β”€ kmr.traineddata
β”‚Β Β  β”œβ”€β”€ osd.traineddata
β”‚Β Β  └── vie.traineddata
β”œβ”€β”€ tessdata_best
β”‚Β Β  β”œβ”€β”€ eng.traineddata
β”‚Β Β  β”œβ”€β”€ fra.traineddata
β”‚Β Β  β”œβ”€β”€ kmr.traineddata
β”‚Β Β  └── osd.traineddata
β”œβ”€β”€ tessdata_fast
β”‚Β Β  β”œβ”€β”€ eng.traineddata
β”‚Β Β  β”œβ”€β”€ kmr.traineddata
β”‚Β Β  β”œβ”€β”€ osd.traineddata
β”‚Β Β  └── script
β”‚Β Β      └── Latin.traineddata
└── tesseract
    ...
    β”œβ”€β”€ test
    β”œβ”€β”€ unittest
    β”‚Β Β  └── third_party/googletest
    └── VERSION

Fonts

Run tests

To run the tests, do the following in tesseract folder

text
autoreconf -fiv
git submodule update --init
git clone https://github.com/egorpugin/tessdata tessdata_unittest --depth 1
cp tessdata_unittest/fonts/* test/testing/
mv tessdata_unittest/* ../
export TESSDATA_PREFIX=/prefix/to/path/to/tessdata
make check

2. Official Technical Reference & Guides (tesseract-ocr/docs)

[The Fourth Annual Test of OCR Accuracy](AT-1995.pdf)

Publication Year: 1995

[An Overview of the Tesseract OCR Engine](tesseracticdar2007.pdf)

Publication Year: 2007

The Tesseract OCR engine, as was the HP Research Prototype in the UNLV Fourth Annual Test of OCR Accuracy[1], is described in a comprehensive overview. Emphasis is placed on aspects that are novel or at least unusual in an OCR engine, including in particular the line finding, features/classification methods, and the adaptive classifier.

[Hybrid Page Layout Analysis via Tab-Stop Detection](PageLayoutAnalysisICDAR2.pdf)

Published at 2009 10 th International Conference on Document Analysis and Recognition.

(source)

A new hybrid page layout analysis algorithm is proposed, which uses bottom-up methods to form an initial data-type hypothesis and locate the tab-stops that were used when the page was formatted. The detected tab-stops are used to deduce the column layout of the page. The column layout is then applied in a top-down manner to impose structure and reading-order on the detected regions. The complete C++ source code implementation is available as part of the Tesseract open source OCR engine athttps://github.com/tesseract-ocr/tesseract.

[Combined Orientation and Script Detection using the Tesseract OCR Engine](Combined_Orientation_and_Script_Detection_using_the_Tesseract_OCR_Engine.pdf)

(source)

Publication Year: 2009

This paper proposes a simple but effective algorithm to estimate the script and dominant page orientation of the text contained in an image. A candidate set of shape classes for each script is generated using synthetically rendered text and used to train a fast shape classifier. At run time, the classifier is applied independently to connected components in the image for each possible orientation of the component, and the accumulated confidence scores are used to determine the best estimate of page orientation and script. Results demonstrate the effectiveness of the approach on a dataset of 1846 documents containing a diverse set of images in 14 scripts and any of four possible page orientations.

[Adapting the Tesseract Open Source OCR Engine for Multilingual OCR](MOCRadaptingtesseract2.pdf)

(source)

Publication Year: 2009

We describe efforts to adapt the Tesseract open source OCR engine for multiple scripts and languages. Effort has been concentrated on enabling generic multi-lingual operation such that negligible customization is required for a new language beyond providing a corpus of text. Although change was required to various modules, including physical layout analysis, and linguistic post-processing, no change was required to the character classifier beyond changing a few limits. The Tesseract classifier has adapted easily to Simplified Chinese. Test results on English, a mixture of European languages, and Russian, taken from a random sample of books, show a reasonably consistent word error rate between 3.72% and 5.78%, and Simplified Chinese has a character error rate of only 3.77%.

Β©ACM, 2009. This is the authors’ version of the work. It is posted here by permission of ACM for your personal use. Not for redistribution. The definitive version was published in Proceedings of the International Workshop on Multilingual OCR 2009, Barcelona, Spain July 25, 2009.

[Table detection in heterogeneous documents](Table_detection_in_heterogeneous_documents.pdf)

(source)

Publication Year: 2010

Detecting tables in document images is important since not only do tables contain important information, but also most of the layout analysis methods fail in the presence of tables in the document image. Existing approaches for table detection mainly focus on detecting tables in single columns of text and do not work reliably on documents with varying layouts. This paper presents a practical algorithm for table detection that works with a high accuracy on documents with varying layouts (company reports, newspaper articles, magazine pages, ...). An open source implementation of the algorithm is provided as part of the Tesseract OCR engine. Evaluation of the algorithm on document images from publicly available UNLV dataset shows competitive performance in comparison to the table detection module of a commercial OCR system.

Comparison to other implementation:

[Limits on the Application of Frequency-based Language Models to OCR](Limits_on_the_Application_of_Frequency-based_Language_Models_to_OCR.pdf)

(source)

Publication Year: 2011

Although large language models are used in speech recognition and machine translation applications, OCR systems are β€œfar behind” in their use of language models. The reason for this is not the laggardness of the OCR community, but the fact that, at high accuracies, a frequency-based language model can do more damage than good, unless carefully applied. This paper presents an analysis of this discrepancy with the help of the Google Books n-gram Corpus, and concludes that noisy-channel models that closely model the underlying classifier and segmentation errors are required.

[Improving Book OCR by Adaptive Language and Image Models](Improving_Book_OCR_by_Adaptive_Language_and_Image_Models.pdf)

(source)

Publication Year: 2012

In order to cope with the vast diversity of book content and typefaces, it is important for OCR systems to leverage the strong consistency within a book but adapt to variations across books. In this work, we describe a system that combines two parallel correction paths using document-specific image and language models. Each model adapts to shapes and vocabularies within a book to identify inconsistencies as correction hypotheses, but relies on the other for effective cross-validation. Using the open source Tesseract engine as baseline, results on a large dataset of scanned books demonstrate that word error rates can be reduced by 25% using this approach.

Tesseract Blends Old and New OCR Technology: Tutorial2 at [DAS2016 – Document Analysis Systems](https://www.primaresearch.org/das2016/tutorials)