最近在看文字识别的实例,也查询不少文章,最后仍是选定开源的引擎(tesseract3.0.1)html
最开始找到的是用微软Office的一个组件实现的,我的感受不是我想要的(要开源啊才是王道)git
http://www.cnblogs.com/vipstone/archive/2011/10/08/2202397.htmlgithub
后面在开源中图看到了开源项目:app
http://www.oschina.net/news/40027/6-opensource-ocr-tools测试
找到了(tesseract )看到学是google开源的还排到第一个因而就找Demothis
是有找到而但老是出了些问题,还加上本身有点晕控制台,就没有太在乎所出的是什么错,再者就是本身暂时不须要因而就放下了google
今天有空就再来拾起看看!spa
第一步:在stackoverflow 上找到了.net
http://stackoverflow.com/questions/15659278/tesseract-3-0-ocr-net-4-0-wrapperdebug
有用的内容以下:
There is now a NuGet Package for the .NET wrapper of charlesw with precompiled versions for all runtimes
http://www.nuget.org/packages/Tesseract/
The project is on:
https://github.com/charlesw/tesseract
Is very important to install Visual Studio 2012 Runtimes on the client machines
http://www.microsoft.com/en-us/download/details.aspx?id=30679
因而我就去在github上下载下来,发现之前也下过,不要紧再下一次就能够了
下载下来打整了几下,我机子报打不到这两个dll(msvcr120.dll,msvcp120.dll),不要紧其余机子上都拷到system32 下就行了!
读取英文没有问题,那咱们来读中方吧,
仍是在stackoverflow下来找到
http://stackoverflow.com/questions/16581626/chinese-character-recognition-using-tesseract-ocr/16582777#16582777
You need to download chinese trained data (it will be a file like chi_sim.traineddata) and add it to your tessdata folder.
To download the file https://code.google.com/p/tesseract-ocr/downloads/detail?name=chi_sim.traineddata.gz
and use like this
Tesseract* tesseract= [[Tesseract alloc] initWithDataPath:@"tessdata" language:@"chi_sim"];
if you have any problem you can download my experiment with tessaract (with chinese language support) from https://github.com/aryansbtloe/ExperimentWithTesseract.git
I have tested this one...Hope you will find this useful.
虽而后他说的是C++中,但语言包应该是同样的,并且之前我也FQ下过简体中文的,也也能够下他提供的github下去下。
各位我用的是Tesseract.ConsoleDemo这个项目来作测试,因而把chi_sim.traineddata文件拷到tessdata这个下面,
Program.cs中将
using (var engine = new TesseractEngine(@"./tessdata", "eng", EngineMode.Default))
改成:
using (var engine = new TesseractEngine(@"./tessdata", "chi_sim", EngineMode.Default))
运行报错了。上次实际都作到这一步了,就是舍不得多走一步,看到一个什么意思,
http://blog.csdn.net/dragoo1/article/details/7961669
简单就是说把tessdata拷贝到exe的所在目录,或者设置TESSDATA_PREFIX环境变量
在bin/debug/tessdata/看了一下,果真后没有chi_sim.traineddata
于把在vs中把这个文件改为始终复制,生成再测试,能够了!