Tesseract 3 语言数据的训练方法
2016-05-14 23:31
369 查看
需要用到的程序
(1) Tesseract 3.00
(2) Tesseract 3.00 Bugfix
(3) CowBoxer 1.01
(4) Universal Extractor 1.61 (非必需)
使用 Universal Extractor 将 Tesseract 的安装包解开,再用 Bugfix 里的 tesseract.exe 覆盖原来的主程序,Tesseract 就可用了。CowBoxer 是用于修改 box 文件的程序。
生成第一个 box 文件
演示中将 Tesseract 解压到了 E:\tesseract-ocr 目录。然后在该目录中建立了一个 build 目录用于存放原始数据和训练过程中生成的文件。原始图片数据一共有 3 个 (test.001.tif - test.003.tif):
![](http://blog.wudilabs.org/?redirect=image_training_tesseract3_test_001)
![](http://blog.wudilabs.org/?redirect=image_training_tesseract3_test_002)
![](http://blog.wudilabs.org/?redirect=image_training_tesseract3_test_003)
首先生成第一个图片 test.001.tif 的 box 文件,这里使用官方的 eng 语言数据进行文字识别:
E:\tesseract-ocr\build>..\tesseract test.001.tif test.001 -l eng batch.nochop makebox
Tesseract Open Source OCR Engine with Leptonica
Number of found pages: 1.
执行完这个命令之后,build 目录下就生成了一个 test.001.box。使用 CowBoxer 打开这个 box 文件,CowBoxer 会自动找到同名的 tif 文件显示出来。
![](http://blog.wudilabs.org/?redirect=image_training_tesseract3_cowboxer_01)
CowBoxer 的使用方法可以看 Help -> About 中的说明。修改完成之后 File -> Save box file 保存文件。
生成初始的 traineddata
接下来使用这一个 box 文件先生成一个 traineddata,在接下来生成其他图片的 box 文件时,使用这个 traineddata 有利于提高识别的正确率,减少修改次数。
..\tesseract test.001.tif test.001 nobatch box.train
..\training\unicharset_extractor test.001.box
..\training\mftraining -U unicharset -O test.unicharset test.001.tr
..\training\cntraining test.001.tr
rename normproto test.normproto
rename Microfeat test.Microfeat
rename inttemp test.inttemp
rename pffmtable test.pffmtable
..\training\combine_tessdata test.
在 build 目录下执行完这一系列命令之后,就生成了可用的 test.traineddata。
生成其余 box 文件
将上一步生成的 test.traineddata 移动到 tesseract-ocr\tessdata 目录中,接下来生成其他 box 文件时就可以通过 -l test 参数使用它了。
..\tesseract test.002.tif test.002 -l test batch.nochop makebox
..\tesseract test.003.tif test.003 -l test batch.nochop makebox
这里仅仅是使用 3 个原始文件作为例子。实际制作训练文件时,什么时候生成一个 traineddata 根据情况而定。中途生成 traineddata 的目的只是为了提高文字识别的准确率,使后面生成的 box 文件能少做修改。
生成最终的 traineddata
在所有的 box 都制作完成后,就可以生成最终的 traineddata 了。
..\tesseract test.001.tif test.001 nobatch box.train
..\tesseract test.002.tif test.002 nobatch box.train
..\tesseract test.003.tif test.003 nobatch box.train
..\training\unicharset_extractor test.001.box test.002.box test.003.box
..\training\mftraining -U unicharset -O test.unicharset test.001.tr test.002.tr test.003.tr
..\training\cntraining test.001.tr test.002.tr test.003.tr
rename normproto test.normproto
rename Microfeat test.Microfeat
rename inttemp test.inttemp
rename pffmtable test.pffmtable
..\training\combine_tessdata test.
在文件较多时可以用程序生成这种脚本执行。
当前语言: 中文 (简体)
(1) Tesseract 3.00
(2) Tesseract 3.00 Bugfix
(3) CowBoxer 1.01
(4) Universal Extractor 1.61 (非必需)
使用 Universal Extractor 将 Tesseract 的安装包解开,再用 Bugfix 里的 tesseract.exe 覆盖原来的主程序,Tesseract 就可用了。CowBoxer 是用于修改 box 文件的程序。
生成第一个 box 文件
演示中将 Tesseract 解压到了 E:\tesseract-ocr 目录。然后在该目录中建立了一个 build 目录用于存放原始数据和训练过程中生成的文件。原始图片数据一共有 3 个 (test.001.tif - test.003.tif):
首先生成第一个图片 test.001.tif 的 box 文件,这里使用官方的 eng 语言数据进行文字识别:
E:\tesseract-ocr\build>..\tesseract test.001.tif test.001 -l eng batch.nochop makebox
Tesseract Open Source OCR Engine with Leptonica
Number of found pages: 1.
执行完这个命令之后,build 目录下就生成了一个 test.001.box。使用 CowBoxer 打开这个 box 文件,CowBoxer 会自动找到同名的 tif 文件显示出来。
CowBoxer 的使用方法可以看 Help -> About 中的说明。修改完成之后 File -> Save box file 保存文件。
生成初始的 traineddata
接下来使用这一个 box 文件先生成一个 traineddata,在接下来生成其他图片的 box 文件时,使用这个 traineddata 有利于提高识别的正确率,减少修改次数。
..\tesseract test.001.tif test.001 nobatch box.train
..\training\unicharset_extractor test.001.box
..\training\mftraining -U unicharset -O test.unicharset test.001.tr
..\training\cntraining test.001.tr
rename normproto test.normproto
rename Microfeat test.Microfeat
rename inttemp test.inttemp
rename pffmtable test.pffmtable
..\training\combine_tessdata test.
在 build 目录下执行完这一系列命令之后,就生成了可用的 test.traineddata。
生成其余 box 文件
将上一步生成的 test.traineddata 移动到 tesseract-ocr\tessdata 目录中,接下来生成其他 box 文件时就可以通过 -l test 参数使用它了。
..\tesseract test.002.tif test.002 -l test batch.nochop makebox
..\tesseract test.003.tif test.003 -l test batch.nochop makebox
这里仅仅是使用 3 个原始文件作为例子。实际制作训练文件时,什么时候生成一个 traineddata 根据情况而定。中途生成 traineddata 的目的只是为了提高文字识别的准确率,使后面生成的 box 文件能少做修改。
生成最终的 traineddata
在所有的 box 都制作完成后,就可以生成最终的 traineddata 了。
..\tesseract test.001.tif test.001 nobatch box.train
..\tesseract test.002.tif test.002 nobatch box.train
..\tesseract test.003.tif test.003 nobatch box.train
..\training\unicharset_extractor test.001.box test.002.box test.003.box
..\training\mftraining -U unicharset -O test.unicharset test.001.tr test.002.tr test.003.tr
..\training\cntraining test.001.tr test.002.tr test.003.tr
rename normproto test.normproto
rename Microfeat test.Microfeat
rename inttemp test.inttemp
rename pffmtable test.pffmtable
..\training\combine_tessdata test.
在文件较多时可以用程序生成这种脚本执行。
当前语言: 中文 (简体)
相关文章推荐
- “进度条”博客——第十一周
- iOS 开发常见问题
- 1. 爬下12306--从0到1
- HDU 2114 Calculate S(n)(立方阶求和公式)
- 第二章 控制结构和函数
- CLR垃圾回收的设计
- (一)JAVA使用POI操作excel
- windows常用DOS
- BZOJ1036 树的统计
- JAVA解析Excel文件的两种方式 --Poi技术
- HDU-3709 Balanced Number (数位DP)
- 爬下12306--目录
- Android存储(读取)之SD卡
- 前端模块化
- Entity Framework 6 Recipes 2nd Edition(13-4)译 -> 有效地创建一个搜索查询
- C#异常处理机制
- Android OpenGL ES(五):GLSurfaceView
- IT十八掌掌第八天课程总结
- 切向量和梯度的关系
- ulua整数溢出的BUG