#安装系统依赖
yum install -y automake autoconf libtool gcc gcc-c++
yum install -y libpng-devel libjpeg-devel libtiff-devel
yum -y install python-devel
yum -y install openssl-devel
yum -y install opencv
yum -y install java-1.8.0-openjdk java-1.8.0-openjdk-devel
yum install -y libffi libffi-devel
#安装leptonica-1.74.4
http://www.leptonica.org/download.html
wget http://linux-1251121573.cosgz.myqcloud.com/soft/tesseract/leptonica-1.74.4.tar.gz
tar xvzf leptonica-1.74.4.tar.gz
cd leptonica-1.74.4/
./configure
make && make install
cd ..
# 安装auto*之类的依赖,目的是为了autogen.sh调用autoreconf生成configure文件wget http://linux-1251121573.cosgz.myqcloud.com/soft/tesseract/autoconf-2.69.tar.gz
tar -zxvf autoconf-2.69.tar.gz
cd autoconf-2.69
./configure
make && make install
cd ..wget http://linux-1251121573.cosgz.myqcloud.com/soft/tesseract/automake-1.14.tar.gz
tar -zxvf automake-1.14.tar.gz
cd automake-1.14
./bootstrap.sh
./configure
make && make install
cd ..wget http://linux-1251121573.cosgz.myqcloud.com/soft/tesseract/autoconf-archive-2018.03.13.tar
xz -d autoconf-archive-2018.03.13.tar.xz
tar xvf autoconf-archive-2018.03.13.tar
cd autoconf-archive-2018.03.13
./configure
make && make install
cd ..# 安装glib之类的依赖
wget http://linux-1251121573.cosgz.myqcloud.com/soft/tesseract/pcre-8.40.tar.gz
tar -zvxf pcre-8.40.tar.gz
cd pcre-8.40
./configure
make
make install
cd ..wget http://linux-1251121573.cosgz.myqcloud.com/soft/tesseract/glib-2.56.1.tar
tar xvf glib-2.56.1.tar
cd glib-2.56.1
./configure --enable-libmount=no
make
make install
cd ..wget http://linux-1251121573.cosgz.myqcloud.com/soft/tesseract/pkg-config-0.29.2.tar.gz
tar -zvxf pkg-config-0.29.2.tar.gz
cd pkg-config-0.29.2
./configure --with-internal-glib
make
make install
cd ..
# 安装pkg-config --- 很多博客没有这一步骤,会报错:Syntax error near unexpected token `LEPTONICA,',参考https://github.com/tesseract-ocr/tesseract/issues/941
wget https://pkg-config.freedesktop.org/releases/pkg-config-0.29.tar.gz
tar -zxvf pkg-config-0.29.tar.gz
cd 进入解压文件夹
./configure --with-internal-glib
make
make install
# 安装tesseract-ocr4.0
wget http://linux-1251121573.cosgz.myqcloud.com/soft/tesseract/4.0.0-beta.1.tar.gz
tar zxvf 4.0.0-beta.1.tar.gz
cd tesseract-4.0.0-beta.1
autoreconf -I /usr/local/share/aclocal
./autogen.sh
./configure --prefix=$HOME/local/
make
make install
vi /etc/profile
添加:
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/leptonica/lib/pkgconfig
export PKG_CONFIG_PATH
CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:/usr/local/leptonica/include/leptonica
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/leptonica/lib
export LD_LIBRARY_PATH
LIBRARY_PATH=$LIBRARY_PATH:/usr/local/leptonica/lib
export LIBRARY_PATH
LIBLEPT_HEADERSDIR=/usr/local/leptonica/include/leptonica
export LIBLEPT_HEADERSDIR
PATH=$PATH:/usr/local/tesseract/bin
export PATH
运行命令:source /etc/profile
# 运行 tesseract提示找不到命令,把/root/local/bin/tesseract文件复制到/usr/bin/目录即可
下载训练模型并移动到文件夹中:
wget http://linux-1251121573.cosgz.myqcloud.com/soft/tesseract/chi_sim.traineddata
wget http://linux-1251121573.cosgz.myqcloud.com/soft/tesseract/eng.traineddatamv chi_sim.traineddata eng.traineddata /usr/local/share/tessdata
vi ~/.bash_profile
添加:
export TESSDATA_PREFIX=/usr/local/share/tessdata/
运行命令:source ~/.bash_profile