您的位置:首页 > 产品设计 > UI/UE

Mac OS X 中 build tesseract source code

2017-03-27 16:41 381 查看
1. 安装homebrew

直接在终端中输入:ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
安装过程中需要键入一次回车

2. 按照Github官方安装依赖

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/[/code]
在这一步可能会有错误提示:
fatal:
could not create work tree dir 'tesseract': Permission denied此时需要我们使用sudo创建一个具有写权限的文件夹也可能有错误提示: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

cd tesseract
./autogen.sh

这一步可能会有错误:“

Failed to find libtoolize or glibtoolize...“

只需安装libtool即可:brew install libtool
./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 这个在官方github上就有,然后把它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 outtest.jpg 为要识别的图片,然后识别结果会存储在out文件中。详细参数参见官方github文档!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: