参考:https://groups.google.com/forum/#!msg/tesseract-ocr/MSYezIbckvs/kO1VoNKMDMQJ 字体
V4版本代码示例 :google
import pytesseract from PIL import Image as img text = pytesseract.image_to_string(img.open('src2\B1.jpg'), lang='teld+chi_sim', config='--psm 3 --oem 1') print(text.replace('”', ''))
合并识别结果spa
在实际使用 tesseract-orc 识别库的时候,初次制做的识别库颇有可能识别率不太理想,须要后期慢慢补充。将多个修正过的box文件合并成一个识别库。
假设已存在以下样品图片和修正过的box文件:code
一、先生成相对应的 .tr 文件orm
二、提取字符blog
三、生成字体特征文件图片
四、执行以下命令get
五、汇集全部.tr 文件string
六、重命名文件it
七、合并全部文件 生成一个大的字库文件
示例代码:
/*生成box文件*/
/*tesseract teld.shz.exp0.tif teld.shz.exp0 -l chi_sim --psm 3 --oem 1 batch.nochop makebox*/ tesseract teld.shz.exp0.tif teld.shz.exp0 -l chi_sim batch.nochop makebox /*生成font_properties文件*/ echo shz 0 0 0 0 0 >font_properties /*生成.tr训练文件*/ tesseract teld.shz.exp0.tif teld.shz.exp0 nobatch box.train /*生成字符集文件*/ unicharset_extractor teld.shz.exp0.box /*生成shape文件*/ shapeclustering -F font_properties -U unicharset teld.shz.exp0.tr /*生成聚字符特征文件*/ mftraining -F font_properties -U unicharset teld.shz.exp0.tr /*生成字符正常化特征文件*/ cntraining teld.shz.exp0.tr /*文件重命名*/ rename normproto teld.normproto rename inttemp teld.inttemp rename pffmtable teld.pffmtable rename shapetable teld.shapetable rename unicharset teld.unicharset /*合并训练文件*/ combine_tessdata teld.
参考资料