惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Spread Privacy
Spread Privacy
P
Palo Alto Networks Blog
P
Proofpoint News Feed
AI
AI
Help Net Security
Help Net Security
S
Securelist
T
Troy Hunt's Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
C
Cisco Blogs
Scott Helme
Scott Helme
Hacker News - Newest:
Hacker News - Newest: "LLM"
Vercel News
Vercel News
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
B
Blog
GbyAI
GbyAI
Recent Commits to openclaw:main
Recent Commits to openclaw:main
D
Darknet – Hacking Tools, Hacker News & Cyber Security
P
Proofpoint News Feed
S
Security Affairs
Cisco Talos Blog
Cisco Talos Blog
AWS News Blog
AWS News Blog
T
Tenable Blog
H
Help Net Security
NISL@THU
NISL@THU
F
Fortinet All Blogs
博客园_首页
G
GRAHAM CLULEY
L
LINUX DO - 最新话题
P
Privacy International News Feed
G
Google Developers Blog
博客园 - Franky
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Security Archives - TechRepublic
Security Archives - TechRepublic
The Register - Security
The Register - Security
L
LangChain Blog
aimingoo的专栏
aimingoo的专栏
T
Tor Project blog
P
Privacy & Cybersecurity Law Blog
量子位
C
Cyber Attacks, Cyber Crime and Cyber Security
Forbes - Security
Forbes - Security
S
Secure Thoughts
Simon Willison's Weblog
Simon Willison's Weblog
D
Docker
Recorded Future
Recorded Future
博客园 - 三生石上(FineUI控件)
L
Lohrmann on Cybersecurity
T
Tailwind CSS Blog

博客园 - 好好学习,天天进步

Java调用ocx控件以及dll pongo英雄会-修路题解(z) 那些VisualStudio隐藏的调试功能(转) Android 横屏切换竖屏Activity的生命周期(转) 那些有争议的编程观点 经过完整测试的农历-公历相互转换 windows phone SDK 8.0 模拟器异常 0x89721800解决办法 JavaScript 解析器相关资料 AST Parser。。。 (转)浏览器的工作原理:新式网络浏览器幕后揭秘 中缀表达式转后缀表达式(逆波兰表达式) Windows 8 无法安装 Algorithm Gossip: 中序式轉後序式(前序式) 透明窗口与不规则窗口制作方法总结 检测文件存在的四种方法 C/C++多种方法获取文件大小 从浏览器启动客户端程序 Struts 2命令执行漏洞 win7 x64怎么枚举所有快捷键呢 在windbg中测试shadow ssdt , win32k!NtUserGetForegroundWindow , hook shadow ssdt
tesseract-ocr训练方法
好好学习,天天进步 · 2012-10-12 · via 博客园 - 好好学习,天天进步

http://www.lixin.me/blog/2012/05/26/29536

tesseract-ocr有2和3两个版本,不同版本训练方法稍有不同。

第3版本的训练方法官版教程在这里:TrainingTesseract3

第2版的训练方法官版教程在这里:TrainingTesseract

我使用的是最新的3.01版本的。训练所需准备:

1.下载并安装3.01版本的tesseract。事实上并不需要安装这步骤,我下载的是压缩包版,解压即可,这里我解压到E:\Tesseract-ocr目录。

2.下载并安装jTessBoxEditor 工具,这是一个Box file editors,用来编辑训练文件的,直接下载地址在这里。这个软件是用java写的,运行需要安装jre,好在这个东西比.net好装多了,怎么运行可以见它的readme文件。

3.一张用来训练的tiff格式图片。

在不通过训练的前提下,使用tesseract来识别一个订单号的内容,如图1发现错误率很高,希望通过训练来提高准确率。

训练过程:

1.通过合并10张如上图的图片合并为一张tiff格式的图片,如何合并呢?通过jTessBoxEditor的Merge Tiff 来完成,不过他的小缺点就是只能合并多张tiff格式的,如果你的图片是jpg的,需要先转换。生成后的tiff图片叫做orderNo.tif

2.Make Box Files。在orderNo.tif所在的目录下打开一个命令行,输入:

E:\Tesseract-ocr\tesseract.exe orderNo.tif orderNo batch.nochop makebox

来生成一个box文件,该文件记录了tesseract识别出来的每一个字和其位置坐标。

3.使用jTessBoxEditor打开orderNo.tif文件,需要记住的是第2步生成的orderNo.box要和这个orderNo.tif文件同在一个目录下。逐个校正文字,后保存。

4.Run Tesseract for Training。输入命令:

E:\Tesseract-ocr\tesseract.exe orderNo.tif orderNo nobatch box.train

5.Compute the Character Set。输入命令:

E:\Tesseract-ocr\unicharset_extractor.exe orderNo.box

6.新建文件“font_properties”。如果是3.01版本,那么需要在目录下新建一个名字为“font_properties”的文件,并且输入文本 :

orderNo 0 0 0 0 0

大致意思就是说orderNo这个语言的字体为普通字体。

并执行命令:

E:\Tesseract-ocr\mftraining.exe -F font_properties -U unicharset orderNo.tr

7.Clustering。输入命令:

E:\Tesseract-ocr\cntraining.exe orderNo.tr

8.此时,在目录下应该生成若干个文件了,把unicharset, inttemp, normproto, pffmtable这四个文件加上前缀“orderNo.”。然后输入命令:

E:\Tesseract-ocr\combine_tessdata.exe orderNo.

会显示一个结果如:

Combining tessdata files
TessdataManager combined tesseract data files.
Offset for type 0 is -1
Offset for type 1 is 108
Offset for type 2 is -1
Offset for type 3 is 1660
Offset for type 4 is 327545
Offset for type 5 is 327781
Offset for type 6 is -1
Offset for type 7 is -1
Offset for type 8 is -1
Offset for type 9 is -1
Offset for type 10 is -1
Offset for type 11 is -1
Offset for type 12 is –1

必须确定的是第2、4、5、6行的数据不是-1,那么一个新的字典就算生成了。

此时目录下“orderNo.traineddata”的文件拷贝到tesseract程序目录下的“tessdata”目录。

以后就可以使用该该字典来识别了,例如:

tesseract.exe test.jpg result –l orderNo

通过训练出来的新语言,识别率提高了不少。