【原创】Tesseract-OCR 3.02 训练笔记

目的:识别http://www.computrabajo.com.mx/bt-ofrd-human1985-207292.htm中的Email地址

官方文档:https://code.google.com/p/tesseract-ocr/wiki/TrainingTesseract3

官方的英文文档很长,这里记录几个关键步骤。

特别注意:训练时用的版本与运行时用的版本一定要保持一致。

 

  • 准备:

1、安装Tesseract

2、下载图片,保存到本地,并转换成Tif格式。

  • Make Box Files

1、tesseract eng.timesitalic.exp0.tif eng.timesitalic.exp0 batch.nochop makebox

2、把生成的box文件用文本编辑器编辑,使之与图片中的文字一致

PS:此步骤亦可以使用jTessBoxEditor工具代替

  • Run Tesseract for Training

tesseract [lang].[fontname].exp[num].tif [lang].[fontname].exp[num] nobatch box.train

此步骤生成一个.tr的文件

  • Compute the Character Set

unicharset_extractor lang.fontname.exp0.box

此步骤生成一个unicharset文件

  • font_properties (new in 3.01)

用记事本新建一个名为font_properties的文件,内容格式为:<fontname> <italic> <bold> <fixed> <serif> <fraktur>

如:timesitalic 1 0 0 1 0

这个步骤要注意:<fontname>应与步骤"Run Tesseract for Training”命令中指定的[fontname]一致,如果没有指定,则为UnknownFont

如:UnknownFont 0 0 0 0 0

  • Clustering

三个命令:

shapeclustering -F font_properties -U unicharset lang.fontname.exp0.tr

mftraining -F font_properties -U unicharset -O lang.unicharset lang.fontname.exp0.tr

cntraining lang.fontname.exp0.tr lang.fontname.exp1.tr

  • Putting it all together

combine_tessdata lang.

注意:一定要把Clustering生成的文件重命名,我在开始训练时,没仔细看官方的最关键的一段话:

That is all there is to it! All you need to do now is collect together all (shapetable, normproto, inttemp, pffmtable) the files and rename them with a lang. prefix, where lang is the 3-letter code for your language taken from http://en.wikipedia.org/wiki/List_of_ISO_639-2_codes

后来在CSDN上看到边城骆驼的博文http://blog.csdn.net/marvinhong/article/details/8459591,才恍然大悟。

  • 测试

tesseract image.tif output -l lang

  • 最后附上几个有用的链接:

tesseract-ocr - An OCR Engine that was developed at HP Labs between 1985 and 1995... and now at Google. - Google Project Hosting

VietOCR | Free Graphics software downloads at SourceForge.net

tesseractdotnet - tesseract-ocr .net - Google Project Hosting

posted @ 2013-04-15 10:10  一 缕 阳 光  阅读(12927)  评论(2编辑  收藏  举报