Tesseract Training Steps¶
Tesseract Training Steps¶
SETUP / DOWNLOADS¶
- Download Tesseract tesseract-ocr-setup-3.02.02.exe (https://github.com/tesseract-ocr/tesseract/wiki/Downloads and https://sourceforge.net/projects/tesseract-ocr-alt/files/)
- Download Tesseract tessdata files tesseract-ocr-3.02.eng.tar.gz (https://github.com/tesseract-ocr/tesseract/wiki/Data-Files#data-files-for-version-302 or https://sourceforge.net/projects/tesseract-ocr-alt/files/)
- Install tesseract and copy tessdata folder into application directory
- Download and install / unzip qt-box-editor-1.08win32.zip into the tesseract folder (http://zdenop.github.io/qt-box-editor/ via https://github.com/zdenop/qt-box-editor/downloads)
- Download and unzip DeSkew (http://galfar.vevb.net/deskew/)
PROCEDURE¶
- Train Tesseract using scanned image(s)
- Filename format: [language].[font name].exp[num]
- input file (sample): eng2.FontName001.exp0.tiff
- language: eng2
- font: FontName001
- Deskew image (auto rotate)
> deskew.exe -b FFFFFF -o eng2.FontName001.exp0.deskew.tiff eng2.FontName001.exp0.tiff
> move /Y eng2.FontName001.exp0.tiff eng2.FontName001.exp0.tiff.original
> move /Y eng2.FontName001.exp0.deskew.tiff eng2.FontName001.exp0.tiff
- Create box file - contains exact locations of each found characters / shapes
- In batch, the following can be used:
tesseract.exe %1 %~n1 batch.nochop makebox - this process will create box file:
eng2.FontName001.exp0.box
Start qt-box-editor-1.08.exe and fix invalid mappings. Save fixed box file.
Run the following command to start training
Detect the Character set used in your box files (can pass *.box for all box files):¶
Create afont_properties file or add to the existing one
- you may add more lines for each of the types, Ex. for bold: FontName001 0 1 0 0 0 Execute shape clustering routine based on the font properties
Run Training using MF and CN training executables
> mftraining -F font_properties -U unicharset -O eng2.unicharset eng2.FontName001.exp0.tr
> cntraining eng2.FontName001.exp0.tr
> move /Y inttemp eng2.inttemp
> move /Y normproto eng2.normproto
> move /Y pffmtable eng2.pffmtable
> move /Y shapetable eng2.shapetable
Combine data into tessdata format (dot at the ned is important)
Copy newly generated trained data file into the tessdata folder
Now you can run tesseract to get text into trained-output.txt file