5

Tesseract系列-How to Build Tesseract 3.04 with VS2013

 2 years ago
source link: https://blog.matrixs.site/post/2016-07-06-tesseract-2-how-to-build-tesseract-3-dot-04-with-vs2013/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

要了解Tesseract OCR除了查阅一些文献,最好能跟跟源码。 由于Google已经开放了Tesseract OCR的源码,通过简单的编译,就能一窥Tesseract OCR的实现;本文是参考了Paul Vorbach的How to build Tesseract 3.03 with Visual Studio 2013以及YangHe’s Blog Visual Studio 2013编译Tesseract 3.04来完成整个编译过程的,并且总结了一些编译过程中遇到的问题。

PS:写这篇Blog时,Tesseract OCR源码已经更新到了3.05,但是本Blog还是对3.04版本进行编译。

编译Leptonica

由于Tesseract OCR整个工程是有依赖第三方库的,这个第三方库就是Leptonica,因此在编译Tesseract工程前,需要先编译下Leptonica。

  1. 创建用来编译Tesseract的目录。这里我们假设是C:\Tesseract-Build
  2. 安装Git后,直接用右键在Tesseract-Build文件夹内选择Git Bash Here
  3. 从GitHub上拷贝依赖文件到当前目录: git clone git://github.com/pvorb/tesseract-vs2013.git
  4. 打开VS2013 Developer Command Prompt
    (这里与YangHe’s Blog里面提到的不同,因为我用他说的工程直接编译出了一堆问题,但是利用Paul Vorbach的方法则顺利完成编译)
  5. 改变路径到\Tesseract-Build\tesseract-vs2013下;
  6. 通过指令msbuild build.proj完成依赖库Leptonica的编译;

编译Tesseract

YangHe’s Blog 和Paul Vorbach都有提供直接从SVN上更新最新版的Tesseract源码,但是我只想要3.04的,所以不得不手动的从GitHub上download了3.04.00版本的源码。之后需要手动配置依赖文件。
(另外再提醒下,两篇博客提供的SVN更新地址都是Tesseract项目还没有移到GitHub的地址,如果想直接从GitHub上更新最新的,需要把地址跟改为https://github.com/tesseract-ocr/tesseract/trunk,而且在天朝最好需要翻墙更新,你懂得)

  1. Tesseract-Build\tesseract-vs2013目录中release\文件夹下的include\lib\两个文件夹Copy至Tesseract-Build\文件夹下
    include\中包括所有Leptonica的头文件及部分其他库的头文件。
  2. Tesseract-Build\目录下新建tesseract-ocr文件夹,将3.04.00版本的所有源码文件Copy至该目录下。
  3. 用VS2013打开tesseract-ocr\vs2010目录下的tesseract.sln工程。
  4. 选择DLL_Debug模式编译下,报了一堆错
    不用紧张,一个个慢慢解决!

解决编译Tesseract时的错误

  1. error C2146: syntax error : missing ‘}’ before identifier ‘銆’
    解决方法: 打开出现warning的文件,Ctrl+A全选,然后在文件菜单:file->advanced save options ,在弹出的选项中选择新的编码方式为:Chinese Simplified ,点击确定,重新编译,该Error就解决了;

  2. error LNK1104: cannot open file ‘liblept171d.lib’
    解决方法:先确认Tesseract-Build\lib\目录下,有如下文件
    若没有,就从Tesseract-Build\lib\Win32\Tesseract-Build\lib\x64\目录下将所需.lib文件Copy至lib目录下;重新编译看是否解决问题;

  3. LIB_Debug模式下编译时,遇到如下错误 解决方法:右键选择工程libtesseract304Properties,删除在Build EventsPre-Build Event中的Command Line的内容即可;

  4. error LNK1104: cannot open file ‘zlib125-static-mtdll-debug.lib’ 解决方法:在Tesseract-Build\tesseract-ocr\vs2010\include\目录下,用编辑器打开leptonica_versionnumbers.props,查找<ZLIB_VERSION>***</ZLIB_VERSION>,将其中的值改为Tesseract-Build\lib\下对应dll的值,例如128


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK