tesseract .net 中使用歷程


最近在看文字識別的實例,也查詢很多文章,最后還是選定開源的引擎(tesseract3.0.1)

最開始找到的是用微軟Office的一個組件實現的,個人感覺不是我想要的(要開源啊才是王道)

http://www.cnblogs.com/vipstone/archive/2011/10/08/2202397.html

后面在開源中圖看到了開源項目:

http://www.oschina.net/news/40027/6-opensource-ocr-tools

找到了(tesseract )看到學是google開源的還排到第一個於是就找Demo

是有找到而但總是出了些問題,還加上自己有點暈控制台,就沒有太在意所出的是什么錯,再者就是自己暫時不需要於是就放下了

今天有空就再來拾起看看!

第一步:在stackoverflow 上找到了

http://stackoverflow.com/questions/15659278/tesseract-3-0-ocr-net-4-0-wrapper

有用的內容如下:

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++中,但語言包應該是一樣的,而且以前我也翻牆下過簡體中文的,也也可以下他提供的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中把這個文件改成始終復制,生成再測試,可以了!

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM