由于tesseract在github上只提供了ubuntu与mac的教程,并且我在部署Centos时遇到了各种难解问题,好不容易部署成功特发表一篇文章记录。
下载tesseract
git clone https://github.com/tesseract-ocr/tesseract.git
- 安装一些常用的包
yum install gtk2-devel yasm glibc.i686 libstdc++.so.6 libgtk-x11-2.0.so libatk-1.0.so.0 libcairo.so.2 libcups.so.2 libgdk-x11-2.0.so.0 libgdk_pixbuf-2.0.so.0 libgtk-x11-2.0.so.0 libpango-1.0.so.0 libpangocairo-1.0.so.0 libICE.so.6 libSM.so.6 libmng.so.1 libpng12.so.0 libGLU.so.1 -y
- 安装开发工具
yum groupinstall "Development Tools"
如需编译训练环境安装icu
- 下载
wget http://download.icu-project.org/files/icu4c/52.1/icu4c-52_1-src.tgz
- 解压
tar -xvzf icu4c-52_1-src.tgz
cd icu/source/
./runConfigureICU Linux --with-library-bits=64
- 编译:
make -j 5
- 安装
make install
- link
ln -s /usr/local/lib/libicui18n.so.52 /usr/lib64/libicui18n.so.52
ln -s /usr/local/lib/libicuio.so.52 /usr/lib64/libicuio.so.52
ln -s /usr/local/lib/libicuuc.so.52 /usr/lib64/libicuuc.so.52
ln -s /usr/local/lib/libicudata.so.52 /usr/lib64/libicudata.so.5
安装leptonica1.7(4.0要修必须在1.74以上)
- 下载
wget http://www.leptonica.org/source/leptonica-1.74.4.tar.gz
- 解压与安装
tar -xzvf leptonica-1.74.4.tar.gz
cd leptonica-1.74.4
./configure --prefix=/usr/local/
make && make install
- 环境变量的配置 :
vim \etc\bashrc
- 在文本最底下添加代码
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH
CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:/usr/local/include/
export CPLUS_INCLUDE_PATH
C_INCLUDE_PATH=$C_INCLUDE_PATH:/usr/local/leptonica/include/leptonica
export C_INCLUDE_PATH
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
export LD_LIBRARY_PATH
LIBRARY_PATH=$LIBRARY_PATH:/usr/local/lib
export LIBRARY_PATH
TESSDATA_PREFIX=/root/tesseract/
export TESSDATA_PREFIX
- 刷新文件
source /etc/bashrc
安装autoconf-archive
- 下载
- 安装
rpm -i autoconf-archive-2016.09.16-1.sdl7.noarch.rpm
- 安装tesseract
回到tesseract目录下按照下列命令依次执行
cd tesseract
./autogen.sh
./configure —prefix=/usr/local/
make install
如还需编译训练环境 命令终端还会有提示
如果你的gcc环境还没支持到c++11 请做下面操作,然后重复上面安装tesseract的步骤
参考链接:http://blog.csdn.net/ppdouble/article/details/52894271
升级c++11
1下载repo文件
wget http://people.centos.org/tru/devtools-2/devtools-2.repo -O /etc/yum.repos.d/devtools-2.repo
2安装
yum install devtoolset-2-gcc devtoolset-2-binutils devtoolset-2-gcc-c++
3创建连接
ln -s /opt/rh/devtoolset-2/root/usr/bin/* /usr/local/bin/