作者电脑:Mac Mini 系统信息:OS X EI Capitan 10.11.6
Tesseract4.0github地址:https://github.com/tesseract-ocr/tesseract/wiki/4.0-with-LSTM
build 步骤:
参考Tesseract github上的官方文档:https://github.com/tesseract-ocr/tesseract/wiki/Compiling#macos
安装homebrew直接在终端中输入:ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
安装过程中需要键入一次回车
2. 使用brew命令安装依赖
brew install automake autoconf brew install autoconf-archive brew install pkgconfig brew install icu4c brew install leptonica brew install gcc 3. compile git clone https://github.com/tesseract-ocr/tesseract/ 在这一步可能会有错误提示:fatal: could not create work tree dir 'tesseract': Permission denied
此时需要我们使用sudo命令创建一个具有写权限的文件夹,然后把tesseract的源码clone至此文件中
也可能有错误提示:
Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo.
我们需要:
1、打开终端,输入 sudo xcodebuild -license
2、终端提示敲回车键(enter)打开许可协议,照做
3、终端提示 按下 “space” 键阅读许可协议,按“q” 不阅读
4、最终,终端会出现三个选项,agree 、print、cancel,不用想,能不是agree 吗!输入agree,然后enter
4. 接下来:
cd tesseract ./autogen.sh 这一步可能会有错误:“Please make sure the TESSDATA_PREFIX environment variable is set to the parent directory of your "tessdata" directory.
就使用命令:export TESSDATA_PREFIX=/Users/naver/code/tesseract/
接下来要提前创建一个文件来存储识别的文字结果,如:out
然后输入测试命令:
tesseract /Users/naver/Downloads/test.jpg out
test.jpg 为要识别的图片,然后识别结果会存储在out文件中。
详细参数介绍参见官方github文档:https://github.com/tesseract-ocr/tesseract/wiki/Command-Line-Usage
https://github.com/tesseract-ocr/tesseract/blob/master/doc/tesseract.1.asc#config-files-and-augmenting-with-user-data
其他参考链接:
http://blog.csdn.net/xiaochunyong/article/details/7193744
http://www.zmonster.me/2015/04/17/tesseract-install-usage.html
http://git.malu.me/tesseract使用记录/
转载于:https://www.cnblogs.com/vincent93/p/6683873.html