1TESSERACT(1)
2============
3:doctype: manpage
4
5NAME
6----
7tesseract - command-line OCR engine
8
9SYNOPSIS
10--------
11*tesseract* 'FILE' 'OUTPUTBASE' ['OPTIONS']... ['CONFIGFILE']...
12
13DESCRIPTION
14-----------
15tesseract(1) is a commercial quality OCR engine originally developed at HP
16between 1985 and 1995. In 1995, this engine was among the top 3 evaluated by
17UNLV. It was open-sourced by HP and UNLV in 2005, and has been developed
18at Google since then.
19
20
21IN/OUT ARGUMENTS
22----------------
23'FILE'::
24  The name of the input file.
25  This can either be an image file or a text file. +
26  Most image file formats (anything readable by Leptonica) are supported. +
27  A text file lists the names of all input images (one image name per line).
28  The results will be combined in a single file for each output file format
29  (txt, pdf, hocr, xml). +
30  If 'FILE' is `stdin` or `-` then the standard input is used.
31
32'OUTPUTBASE'::
33  The basename of the output file (to which the appropriate extension
34  will be appended).  By default the output will be a text file
35  with `.txt` added to the basename unless there are one or more
36  parameters set which explicitly specify the desired output. +
37  If 'OUTPUTBASE' is `stdout` or `-` then the standard output is used.
38
39
40[[TESSDATADIR]]
41OPTIONS
42-------
43*-c* 'CONFIGVAR=VALUE'::
44  Set value for parameter 'CONFIGVAR' to VALUE. Multiple *-c* arguments are allowed.
45
46*--dpi* 'N'::
47  Specify the resolution 'N' in DPI for the input image(s).
48  A typical value for 'N' is `300`. Without this option,
49  the resolution is read from the metadata included in the image.
50  If an image does not include that information, Tesseract tries to guess it.
51
52*-l* 'LANG'::
53*-l* 'SCRIPT'::
54  The language or script to use.
55  If none is specified, `eng` (English) is assumed.
56  Multiple languages may be specified, separated by plus characters.
57  Tesseract uses 3-character ISO 639-2 language codes
58  (see <<LANGUAGES,*LANGUAGES AND SCRIPTS*>>).
59
60*--psm* 'N'::
61  Set Tesseract to only run a subset of layout analysis and assume
62  a certain form of image. The options for 'N' are:
63
64  0 = Orientation and script detection (OSD) only.
65  1 = Automatic page segmentation with OSD.
66  2 = Automatic page segmentation, but no OSD, or OCR. (not implemented)
67  3 = Fully automatic page segmentation, but no OSD. (Default)
68  4 = Assume a single column of text of variable sizes.
69  5 = Assume a single uniform block of vertically aligned text.
70  6 = Assume a single uniform block of text.
71  7 = Treat the image as a single text line.
72  8 = Treat the image as a single word.
73  9 = Treat the image as a single word in a circle.
74  10 = Treat the image as a single character.
75  11 = Sparse text. Find as much text as possible in no particular order.
76  12 = Sparse text with OSD.
77  13 = Raw line. Treat the image as a single text line,
78       bypassing hacks that are Tesseract-specific.
79
80*--oem* 'N'::
81  Specify OCR Engine mode. The options for 'N' are:
82
83  0 = Original Tesseract only.
84  1 = Neural nets LSTM only.
85  2 = Tesseract + LSTM.
86  3 = Default, based on what is available.
87
88*--tessdata-dir* 'PATH'::
89  Specify the location of tessdata path.
90
91*--user-patterns* 'FILE'::
92  Specify the location of user patterns file.
93
94*--user-words* 'FILE'::
95  Specify the location of user words file.
96
97[[CONFIGFILE]]
98'CONFIGFILE'::
99  The name of a config to use. The name can be a file in `tessdata/configs`
100  or `tessdata/tessconfigs`, or an absolute or relative file path.
101  A config is a plain text file which contains a list of parameters and
102  their values, one per line, with a space separating parameter from value. +
103  Interesting config files include:
104
105  * *alto* -- Output in ALTO format ('OUTPUTBASE'`.xml`).
106  * *hocr* -- Output in hOCR format ('OUTPUTBASE'`.hocr`).
107  * *pdf* -- Output PDF ('OUTPUTBASE'`.pdf`).
108  * *tsv* -- Output TSV ('OUTPUTBASE'`.tsv`).
109  * *txt* -- Output plain text ('OUTPUTBASE'`.txt`).
110  * *get.images* -- Write processed input images to file ('OUTPUTBASE'`.processedPAGENUMBER.tif`).
111  * *logfile* -- Redirect debug messages to file (`tesseract.log`).
112  * *lstm.train* -- Output files used by LSTM training ('OUTPUTBASE'`.lstmf`).
113  * *makebox* -- Write box file ('OUTPUTBASE'`.box`).
114  * *quiet* -- Redirect debug messages to '/dev/null'.
115
116It is possible to select several config files, for example
117`tesseract image.png demo alto hocr pdf txt` will create four output files
118`demo.alto`, `demo.hocr`, `demo.pdf` and `demo.txt` with the OCR results.
119
120*Nota bene:*   The options *-l* 'LANG', *-l* 'SCRIPT' and *--psm* 'N'
121must occur before any 'CONFIGFILE'.
122
123
124SINGLE OPTIONS
125--------------
126*-h, --help*::
127  Show help message.
128
129*--help-extra*::
130  Show extra help for advanced users.
131
132*--help-psm*::
133  Show page segmentation modes.
134
135*--help-oem*::
136  Show OCR Engine modes.
137
138*-v, --version*::
139  Returns the current version of the tesseract(1) executable.
140
141*--list-langs*::
142  List available languages for tesseract engine.
143  Can be used with *--tessdata-dir* 'PATH'.
144
145*--print-parameters*::
146  Print tesseract parameters.
147
148
149[[LANGUAGES]]
150LANGUAGES AND SCRIPTS
151---------------------
152
153To recognize some text with Tesseract, it is normally necessary to specify
154the language(s) or script(s) of the text (unless it is English text which is
155supported by default) using *-l* 'LANG' or *-l* 'SCRIPT'.
156
157Selecting a language automatically also selects the language specific
158character set and dictionary (word list).
159
160Selecting a script typically selects all characters of that script
161which can be from different languages. The dictionary which is included
162also contains a mix from different languages.
163In most cases, a script also supports English.
164So it is possible to recognize a language that has not been specifically
165trained for by using traineddata for the script it is written in.
166
167More than one language or script may be specified by using `+`.
168Example: `tesseract myimage.png myimage -l eng+deu+fra`.
169
170https://github.com/tesseract-ocr/tessdata_fast provides fast language and
171script models which are also part of Linux distributions.
172
173For Tesseract 4, `tessdata_fast` includes traineddata files for the
174following languages:
175
176*afr* (Afrikaans),
177*amh* (Amharic),
178*ara* (Arabic),
179*asm* (Assamese),
180*aze* (Azerbaijani),
181*aze_cyrl* (Azerbaijani - Cyrilic),
182*bel* (Belarusian),
183*ben* (Bengali),
184*bod* (Tibetan),
185*bos* (Bosnian),
186*bre* (Breton),
187*bul* (Bulgarian),
188*cat* (Catalan; Valencian),
189*ceb* (Cebuano),
190*ces* (Czech),
191*chi_sim* (Chinese simplified),
192*chi_tra* (Chinese traditional),
193*chr* (Cherokee),
194*cos* (Corsican),
195*cym* (Welsh),
196*dan* (Danish),
197*deu* (German),
198*div* (Dhivehi),
199*dzo* (Dzongkha),
200*ell* (Greek, Modern, 1453-),
201*eng* (English),
202*enm* (English, Middle, 1100-1500),
203*epo* (Esperanto),
204*equ* (Math / equation detection module),
205*est* (Estonian),
206*eus* (Basque),
207*fas* (Persian),
208*fao* (Faroese),
209*fil* (Filipino),
210*fin* (Finnish),
211*fra* (French),
212*frk* (Frankish),
213*frm* (French, Middle, ca.1400-1600),
214*fry* (West Frisian),
215*gla* (Scottish Gaelic),
216*gle* (Irish),
217*glg* (Galician),
218*grc* (Greek, Ancient, to 1453),
219*guj* (Gujarati),
220*hat* (Haitian; Haitian Creole),
221*heb* (Hebrew),
222*hin* (Hindi),
223*hrv* (Croatian),
224*hun* (Hungarian),
225*hye* (Armenian),
226*iku* (Inuktitut),
227*ind* (Indonesian),
228*isl* (Icelandic),
229*ita* (Italian),
230*ita_old* (Italian - Old),
231*jav* (Javanese),
232*jpn* (Japanese),
233*kan* (Kannada),
234*kat* (Georgian),
235*kat_old* (Georgian - Old),
236*kaz* (Kazakh),
237*khm* (Central Khmer),
238*kir* (Kirghiz; Kyrgyz),
239*kmr* (Kurdish Kurmanji),
240*kor* (Korean),
241*kor_vert* (Korean vertical),
242*lao* (Lao),
243*lat* (Latin),
244*lav* (Latvian),
245*lit* (Lithuanian),
246*ltz* (Luxembourgish),
247*mal* (Malayalam),
248*mar* (Marathi),
249*mkd* (Macedonian),
250*mlt* (Maltese),
251*mon* (Mongolian),
252*mri* (Maori),
253*msa* (Malay),
254*mya* (Burmese),
255*nep* (Nepali),
256*nld* (Dutch; Flemish),
257*nor* (Norwegian),
258*oci* (Occitan post 1500),
259*ori* (Oriya),
260*osd* (Orientation and script detection module),
261*pan* (Panjabi; Punjabi),
262*pol* (Polish),
263*por* (Portuguese),
264*pus* (Pushto; Pashto),
265*que* (Quechua),
266*ron* (Romanian; Moldavian; Moldovan),
267*rus* (Russian),
268*san* (Sanskrit),
269*sin* (Sinhala; Sinhalese),
270*slk* (Slovak),
271*slv* (Slovenian),
272*snd* (Sindhi),
273*spa* (Spanish; Castilian),
274*spa_old* (Spanish; Castilian - Old),
275*sqi* (Albanian),
276*srp* (Serbian),
277*srp_latn* (Serbian - Latin),
278*sun* (Sundanese),
279*swa* (Swahili),
280*swe* (Swedish),
281*syr* (Syriac),
282*tam* (Tamil),
283*tat* (Tatar),
284*tel* (Telugu),
285*tgk* (Tajik),
286*tha* (Thai),
287*tir* (Tigrinya),
288*ton* (Tonga),
289*tur* (Turkish),
290*uig* (Uighur; Uyghur),
291*ukr* (Ukrainian),
292*urd* (Urdu),
293*uzb* (Uzbek),
294*uzb_cyrl* (Uzbek - Cyrilic),
295*vie* (Vietnamese),
296*yid* (Yiddish),
297*yor* (Yoruba)
298
299To use a non-standard language pack named `foo.traineddata`, set the
300`TESSDATA_PREFIX` environment variable so the file can be found at
301`TESSDATA_PREFIX/tessdata/foo.traineddata` and give Tesseract the
302argument *-l* `foo`.
303
304For Tesseract 4, `tessdata_fast` includes traineddata files for the
305following scripts:
306
307*Arabic*,
308*Armenian*,
309*Bengali*,
310*Canadian_Aboriginal*,
311*Cherokee*,
312*Cyrillic*,
313*Devanagari*,
314*Ethiopic*,
315*Fraktur*,
316*Georgian*,
317*Greek*,
318*Gujarati*,
319*Gurmukhi*,
320*HanS* (Han simplified),
321*HanS_vert* (Han simplified, vertical),
322*HanT* (Han traditional),
323*HanT_vert* (Han traditional, vertical),
324*Hangul*,
325*Hangul_vert* (Hangul vertical),
326*Hebrew*,
327*Japanese*,
328*Japanese_vert* (Japanese vertical),
329*Kannada*,
330*Khmer*,
331*Lao*,
332*Latin*,
333*Malayalam*,
334*Myanmar*,
335*Oriya* (Odia),
336*Sinhala*,
337*Syriac*,
338*Tamil*,
339*Telugu*,
340*Thaana*,
341*Thai*,
342*Tibetan*,
343*Vietnamese*.
344
345The same languages and scripts are available from
346https://github.com/tesseract-ocr/tessdata_best.
347`tessdata_best` provides slow language and script models.
348These models are needed for training. They also can give better OCR results,
349but the recognition takes much more time.
350
351Both `tessdata_fast` and `tessdata_best` only support the LSTM OCR engine.
352
353There is a third repository, https://github.com/tesseract-ocr/tessdata,
354with models which support both the Tesseract 3 legacy OCR engine and the
355Tesseract 4 LSTM OCR engine.
356
357
358CONFIG FILES AND AUGMENTING WITH USER DATA
359------------------------------------------
360
361Tesseract config files consist of lines with parameter-value pairs (space
362separated).  The parameters are documented as flags in the source code like
363the following one in tesseractclass.h:
364
365`STRING_VAR_H(tessedit_char_blacklist, "",
366             "Blacklist of chars not to recognize");`
367
368These parameters may enable or disable various features of the engine, and
369may cause it to load (or not load) various data.  For instance, let's suppose
370you want to OCR in English, but suppress the normal dictionary and load an
371alternative word list and an alternative list of patterns -- these two files
372are the most commonly used extra data files.
373
374If your language pack is in '/path/to/eng.traineddata' and the hocr config
375is in '/path/to/configs/hocr' then create three new files:
376
377'/path/to/eng.user-words':
378[verse]
379the
380quick
381brown
382fox
383jumped
384
385'/path/to/eng.user-patterns':
386[verse]
3871-\d\d\d-GOOG-411
388www.\n\\\*.com
389
390'/path/to/configs/bazaar':
391[verse]
392load_system_dawg     F
393load_freq_dawg       F
394user_words_suffix    user-words
395user_patterns_suffix user-patterns
396
397Now, if you pass the word 'bazaar' as a <<CONFIGFILE,'CONFIGFILE'>> to
398Tesseract, Tesseract will not bother loading the system dictionary nor
399the dictionary of frequent words and will load and use the 'eng.user-words'
400and 'eng.user-patterns' files you provided.  The former is a simple word list,
401one per line.  The format of the latter is documented in 'dict/trie.h'
402on 'read_pattern_list()'.
403
404
405ENVIRONMENT VARIABLES
406---------------------
407*`TESSDATA_PREFIX`*::
408  If the `TESSDATA_PREFIX` is set to a path, then that path is used to
409  find the `tessdata` directory with language and script recognition
410  models and config files.
411  Using <<TESSDATADIR,*--tessdata-dir* 'PATH'>> is the recommended alternative.
412*`OMP_THREAD_LIMIT`*::
413  If the `tesseract` executable was built with multithreading support,
414  it will normally use four CPU cores for the OCR process. While this
415  can be faster for a single image, it gives bad performance if the host
416  computer provides less than four CPU cores or if OCR is made for many images.
417  Only a single CPU core is used with `OMP_THREAD_LIMIT=1`.
418
419
420HISTORY
421-------
422The engine was developed at Hewlett Packard Laboratories Bristol and at
423Hewlett Packard Co, Greeley Colorado between 1985 and 1994, with some more
424changes made in 1996 to port to Windows, and some $$C++$$izing in 1998. A
425lot of the code was written in C, and then some more was written in $$C++$$.
426The $$C++$$ code makes heavy use of a list system using macros. This predates
427STL, was portable before STL, and is more efficient than STL lists, but has
428the big negative that if you do get a segmentation violation, it is hard to
429debug.
430
431Version 2.00 brought Unicode (UTF-8) support, six languages, and the ability
432to train Tesseract.
433
434Tesseract was included in UNLV's Fourth Annual Test of OCR Accuracy.
435See <https://github.com/tesseract-ocr/docs/blob/main/AT-1995.pdf>.
436Since Tesseract 2.00,
437scripts are now included to allow anyone to reproduce some of these tests.
438See <https://tesseract-ocr.github.io/tessdoc/TestingTesseract.html> for more
439details.
440
441Tesseract 3.00 added a number of new languages, including Chinese, Japanese,
442and Korean. It also introduced a new, single-file based system of managing
443language data.
444
445Tesseract 3.02 added BiDirectional text support, the ability to recognize
446multiple languages in a single image, and improved layout analysis.
447
448Tesseract 4 adds a new neural net (LSTM) based OCR engine which is focused
449on line recognition, but also still supports the legacy Tesseract OCR engine of
450Tesseract 3 which works by recognizing character patterns. Compatibility with
451Tesseract 3 is enabled by `--oem 0`. This also needs traineddata files which
452support the legacy engine, for example those from the tessdata repository
453(https://github.com/tesseract-ocr/tessdata).
454
455For further details, see the release notes in the Tesseract documentation
456(<https://tesseract-ocr.github.io/tessdoc/ReleaseNotes.html>).
457
458
459RESOURCES
460---------
461Main web site: <https://github.com/tesseract-ocr> +
462User forum: <https://groups.google.com/g/tesseract-ocr> +
463Documentation: <https://tesseract-ocr.github.io/> +
464Information on training: <https://tesseract-ocr.github.io/tessdoc/Training-Tesseract.html>
465
466SEE ALSO
467--------
468ambiguous_words(1), cntraining(1), combine_tessdata(1), dawg2wordlist(1),
469shape_training(1), mftraining(1), unicharambigs(5), unicharset(5),
470unicharset_extractor(1), wordlist2dawg(1)
471
472AUTHOR
473------
474Tesseract development was led at Hewlett-Packard and Google by Ray Smith.
475The development team has included:
476
477Ahmad Abdulkader, Chris Newton, Dan Johnson, Dar-Shyang Lee, David Eger,
478Eric Wiseblatt, Faisal Shafait, Hiroshi Takenaka, Joe Liu, Joern Wanke,
479Mark Seaman, Mickey Namiki, Nicholas Beato, Oded Fuhrmann, Phil Cheatle,
480Pingping Xiu, Pong Eksombatchai (Chantat), Ranjith Unnikrishnan, Raquel
481Romano, Ray Smith, Rika Antonova, Robert Moss, Samuel Charron, Sheelagh
482Lloyd, Shobhit Saxena, and Thomas Kielbus.
483
484For a list of contributors see
485<https://github.com/tesseract-ocr/tesseract/blob/main/AUTHORS>.
486
487COPYING
488-------
489Licensed under the Apache License, Version 2.0
490