Windows(VS2008) 下 build tesseract

参考:http://www.myexception.cn/vsts/1118613.html


Build 过程:

  1. 选定tesseract 主目录,比如 E:\tesseract
  2. 在E:\tesseract 下创建子目录 tesseract-svn,从该子目录拉tesseract svn代码:svn checkout http://tesseract-ocr.googlecode.com/svn/trunk/ (tesseract svn相关页面
  3. Leptonica  download页面下载 leptonica-1.68-win32-lib-include-dirs.zip
  4. 在E:\tesseract 下创建子目录 lib 和 include,将leptonica-1.68-win32-lib-include-dirs.zip 解压后的include 路径下所有文件和子文件夹copy到 E:\tesseract\include 中,将 leptonica-1.68-win32-lib-include-dirs.zip 解压后的lib 路径下所有文件copy到 E:\tesseract\lib 中
  5. 打开 E:\tesseract\tesseract-svn\vs2008\tesseract.sln,build libtesseract302 工程(默认是DLL _Debug),在E:\tesseract\tesseract-svn\vs2008\DLL_Debug下会生成libtesseract302d.dll 和libtesseract302d.lib。其他版本,如DLL_Release,做法类似。
  6. 在E:\tesseract 下创建子目录tessdata,从这里下载tesseract-ocr-3.02.eng.tar.gz、tesseract-ocr-3.02.chi_sim.tar.gz 和 tesseract-ocr-3.02.chi_tra.tar.gz,将它们都解压到E:\tesseract\tessdata中
  7. 添加环境变量 TESSDATA_PREFIX,值为tessdata文件夹的上一级文件夹,即 E:\tesseract


运行:

在E:\tesseract\pic 下创建英文文本截图文件 eng.png
cd E:\tesseract\tesseract-svn\vs2008\LIB_Debug
tesseractd.exe E:\tesseract\pic\eng.png E:\tesseract\pic\eng
会在E:\tesseract\pic 下生成识别出来的文本文件 eng.txt


注意事项:

1)build 过程中,遇到下面的问题
error PRJ0002 : Error result 31 returned from 'C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\mt.exe'
解决办法:Properties -> Configuration Properties -> Linker -> Manifest File, set Generate Manifest to No


2)VS2008中,可能会遇到 带有中文字符编码的源文件编译报错的问题:ccmain/equationdetect.cpp
1>..\..\ccmain\equationdetect.cpp(251) : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
1>..\..\ccmain\equationdetect.cpp(251) : error C2146: syntax error : missing '}' before identifier '銆'
1>..\..\ccmain\equationdetect.cpp(251) : error C2146: syntax error : missing ';' before identifier '銆'
1>..\..\ccmain\equationdetect.cpp(251) : error C2065: '銆' : undeclared identifier
1>..\..\ccmain\equationdetect.cpp(251) : error C2146: syntax error : missing ';' before identifier '銆'
1>..\..\ccmain\equationdetect.cpp(251) : error C2065: '銆' : undeclared identifier
1>..\..\ccmain\equationdetect.cpp(251) : error C2146: syntax error : missing ';' before identifier '銆'
1>..\..\ccmain\equationdetect.cpp(251) : error C2065: '銆' : undeclared identifier
1>..\..\ccmain\equationdetect.cpp(251) : error C2143: syntax error : missing ';' before '}'
1>..\..\ccmain\equationdetect.cpp(253) : error C2065: 'kCharsToEx' : undeclared identifier
解决办法:全选编码出错的源文件,在VS2008中,File => Advanced Save Options => Encoding选择“Chinese Simplified (GB2312) - Codepage 936”


3)以下工程只能以LIB_Debug 或LIB_Release方式build,用DLL方式build会出错(tesseract官网有说明):
ambiguous_words
classifier_tester
cntraining
combine_tessdata
dawg2wordlist
mftraining
shapeclustering
unicharset_extractor
wordlist2dawg


4)运行tesseract的exe时,遇到下面的问题
"The program can't start because liblept168.dll is missing from your computer"
请将E:\tesseract\lib\liblept168.dll 或E:\tesseract\lib\liblept168d.dll copy到tesseract的exe所在目录


5)上面的build过程中,示例的 tesseract目录结构如下:


E:\tesseract\tessdata 下的文件类似:


6)添加了环境变量TESSDATA_PREFIX 之后,如果tesseract.exe还是不能正常工作,请将cmd终端关闭后重新打开,再重试。


7)添加了环境变量TESSDATA_PREFIX 之后,调试tesseract工程时,总是识别失败,结果发现时执行getenv() 函数获取环境变量TESSDATA_PREFIX 值的时候失败了(ln 54):

解决办法:关闭VC重新打开,再重试

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值