做者电脑:Mac Mini 系统信息:OS X EI Capitan 10.11.6html
Tesseract4.0github地址:https://github.com/tesseract-ocr/tesseract/wiki/4.0-with-LSTMgit
build 步骤:github
参考Tesseract github上的官方文档:https://github.com/tesseract-ocr/tesseract/wiki/Compiling#macosmacos
直接在终端中输入:ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"c#
安装过程当中须要键入一次回车api
2. 使用brew命令安装依赖xcode
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 deniedruby
此时须要咱们使用sudo命令建立一个具备写权限的文件夹,而后把tesseract的源码clone至此文件中curl
也可能有错误提示:测试
Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo.
咱们须要:
一、打开终端,输入 sudo xcodebuild -license
二、终端提示敲回车键(enter)打开许可协议,照作
三、终端提示 按下 “space” 键阅读许可协议,按“q” 不阅读
四、最终,终端会出现三个选项,agree 、print、cancel,不用想,能不是agree 吗!输入agree,而后enter
4. 接下来:
cd tesseract
./autogen.sh
这一步可能会有错误:“
./configure CC=gcc-6 CXX=g++-6 CPPFLAGS=-I/usr/local/opt/icu4c/include LDFLAGS=-L/usr/local/opt/icu4c/lib
make -j
sudo make install # if desired
make training
5.试一下好很差使
首先要下载相关语言的数据文件,英语数据文件下载地址:eng.traineddata 其余数据文件下载地址:https://github.com/tesseract-ocr/tesseract/wiki/Data-Files#data-files-for-version-400
数据文件下载完成后,须要把它move到:/tesseract/tessdata 路径下
而后若是出现错误:
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
其余参考连接:
http://blog.csdn.net/xiaochunyong/article/details/7193744
http://www.zmonster.me/2015/04/17/tesseract-install-usage.html
http://git.malu.me/tesseract%E4%BD%BF%E7%94%A8%E8%AE%B0%E5%BD%95/