zoukankan      html  css  js  c++  java
  • tesseract .net 中使用历程

    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++中,但语言包应该是一样的,而且以前我也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中把这个文件改成始终复制,生成再测试,可以了!

  • 相关阅读:
    <把时间当做朋友>读书笔记
    C语言-第12课
    C语言-第13课
    C语言-第11课
    python-第三课-字符串详解
    C语言-第10课
    C语言-第9课
    C语言-第8课
    C语言-第7课-enum和typedef分析
    C语言-第6课
  • 原文地址:https://www.cnblogs.com/gongwei1987/p/9100690.html
Copyright © 2011-2022 走看看