tesseract 中文二次训练

tesseract4.0以上版本可参考 https://github.com/tesseract-ocr/tesseract/wiki/TrainingTesseract-4.00#tutorial-guide-to-lstmtraining

1. jTessBoxEditor 下载安装: https://sourceforge.net/projects/vietocr/files/jTessBoxEditor/

2. 收集样本图像。(从图片自动生成)

text2image –text=training_text.txt –outputbase=cert.normal.exp0 –font=FreeMono –fonts_dir=/usr/share/fonts/truetype/freefont/

3.合并样本图像。运行jTessBoxEditor工具,在点击菜单栏中Tools--->Merge TIFF。在弹出的对话框中选择样本图像(按Shift选择多张),合并成num.font.exp0.tif文件。

java -jar jTessBoxEditor.jar 

# 或者
mogrify -format tif *.jpg
cat *.tif > cert.normal.exp0.tif

4.生成Box File文件。打开命令行,执行命令: 

tesseract cert.normal.exp0.tif cert.normal.exp0 -l chi_sim -psm 6 batch.nochop makebox

5. 打开jTessBoxEditor矫正错误并训练

6.  训练

新建一个font_properties文件,里面内容写入 normal 0 0 0 0 0 表示默认普通字体

tesseract cert.normal.exp0.tif cert.normal.exp0 nobatch box.train
unicharset_extractor cert.normal.exp0.box

shapeclustering -F font_properties -U unicharset cert.normal.exp0.tr
mftraining -F font_properties -U unicharset -O unicharset cert.normal.exp0.tr
cntraining cert.normal.exp0.tr 

 最后会生成五个文件,把目录下的unicharset、inttemp、pffmtable、shapetable、normproto这五个文件前面都加上cert.

如图:

命令行输入,合并五个文件:

combine_tessdata cert.

参考:

1. http://www.cnblogs.com/wzben/p/5930538.html

2. http://blog.csdn.net/yimingsilence/article/details/51353772

3. https://github.com/tesseract-ocr/tesseract/wiki/TrainingTesseract-4.00#tutorial-guide-to-lstmtraining

4. http://docs.oracle.com/cd/E56344_01/html/E54075/mogrify-1.html 命令手册

5. http://www.cnblogs.com/robben/p/4315123.html convert mogrify 命令使用

原文地址:https://www.cnblogs.com/jkmiao/p/6805903.html