成功训练Tesseract识别瘦金体(其中的24个字:))
--插播--
非常好的训练文件,来自 the Early Modern OCR Project (eMOP)。应该是PRIMALabs的工作。
TesseractTraining
Testing with Tesseract
网上很多资源。列几个步骤明确表达清晰的:
利用jTessBoxEditor工具进行Tesseract3.02.02样本训练,提高验证码识别率
- 提到了合并样本图片。Multi-page TIFF file。
- 注意: DO NOT MIX FONTS IN AN IMAGE FILE (In a single .tr file to be precise.)
- 有输出中间过程的console结果,可以对照自己训练时的输出,非常有用
- 用到了shapeclustering (有一些教程没有用这个功能好像也没问题?)
- 最后有步骤列表:
1、合并图片
2、生成box文件
tesseract langyp.fontyp.exp0.tif langyp.fontyp.exp0 -l eng -psm 7 batch.nochop makebox
3、修改box文件
4、生成font_properties
echo fontyp 0 0 0 0 0 >font_properties
5、生成训练文件
tesseract langyp.fontyp.exp0.tif langyp.fontyp.exp0 -l eng -psm 7 nobatch box.train
6、生成字符集文件
unicharset_extractor langyp.fontyp.exp0.box
7、生成shape文件
shapeclustering -F font_properties -U unicharset -O langyp.unicharset langyp.fontyp.exp0.tr
8、生成聚集字符特征文件
mftraining -F font_properties -U unicharset -O langyp.unicharset langyp.fontyp.exp0.tr
9、生成字符正常化特征文件
cntraining langyp.fontyp.exp0.tr
10、更名
rename normproto fontyp.normproto
rename inttemp fontyp.inttemp
rename pffmtable fontyp.pffmtable
rename unicharset fontyp.unicharset
rename shapetable fontyp.shapetable
11、合并训练文件,生成fontyp.traineddata
combine_tessdata fontyp.
我的训练结果
- 上面第5步,真正重要的步骤。官网说用什么语言没关系。测试时发现用默认英语好像错误多一些?
tesseract.exe chi.slimqjs.exp0.tif chi.slimqjs.exp0 nobatch box.train
Tesseract Open Source OCR Engine v3.05.00dev with Leptonica
Page 1
row xheight=86, but median xheight = 0.5
row xheight=77, but median xheight = 0.5
row xheight=68, but median xheight = 0.5
row xheight=77, but median xheight = 0.5
FAIL!
APPLY_BOXES: boxfile line 1/里 ((73,490),(185,582)): FAILURE! Couldn’t find a matching blob
FAIL!
APPLY_BOXES: boxfile line 2/凤 ((226,480),(355,600)): FAILURE! Couldn’t find a matching blob
FAIL!
APPLY_BOXES: boxfile line 5/露 ((677,478),(803,603)): FAILURE! Couldn’t find a matching blob
FAIL!
APPLY_BOXES: boxfile line 6/魁 ((828,480),(951,592)): FAILURE! Couldn’t find a matching blob
APPL