1、快捷安装依赖包
yum -y install automake libtool libtiff-devel libjpeg-devel libpng-devel
还有个pkg-config包yum源里没有,需要下载后在安装
下载pkg-config: wget https://pkg-config.freedesktop.org/releases/pkg-config-0.29.tar.gz
解压:tar -xvf pkg-config-0.29.tar.gz
cd pkg-config-0.29/
./configure --with-internal-glib
make
make check
make install
pkg-config安装完成
注意:不安装pkg-config,等下./configure Tesseract时会出现以下错误:
configure: error: Leptonica 1.74 or higher is required. Try to install libleptonica-dev package.
2、编译安装Leptonica
在官方source下载页面可找到最新的Leptonica
在这以leptonica-1.78.0为例
wget http://www.leptonica.org/source/leptonica-1.78.0.tar.gz
tar -zxvf leptonica-1.78.0.tar.gz
cd leptonica-1.78.0/
./configure
make && make install
确认 /usr/local/include/leptonica 存在所需头文件。
确认 /usr/local/lib 存在 Leptonica 库。
将leptonica加入系统变量中
vim /etc/profile
在文末加入:
export LD_LIBRARY_PATH=$LD_LIBRARY_PAYT:/usr/local/lib
export LIBLEPT_HEADERSDIR=/usr/local/include
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
保存退出后运行:
source /etc/profile
3、编译安装Tesseract
以下以4.1.0为例
wget https://codeload.github.com/tesseract-ocr/tesseract/tar.gz/4.1.0
tar -xvf 4.1.0
cd tesseract-4.1.0/
./autogen.sh
./configure --with-extra-includes=/usr/local/include --with-extra-libraries=/usr/local/lib
make && make install
4、验证
tesseract -v