Centos 6.5上的Tesseract 4.0安装

Tesseract 4.0在Centos 6上安装,存在很多坑,花了不少时间来处理,所以在这里给大家共享一下。

1.安装依赖工具

yum install autoconf automake libtool libjpeg-devel libpng-devel libtiff-devel zlib-devel

在centos上的yum的autoconf版本是2.63,安装tesseract需要2.69,所以需要先手动升级autoconf

查看当前autoconf版本

rpm -qf /usr/bin/autoconf
autoconf-2.63-5.1.el6.noarch

卸载

rpm -e --nodeps autoconf-2.63

安装autoconf 2.69

wget ftp://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz
tar zxvf autoconf-2.69.tar.gz
cd autoconf-2.69
./configure
make
make install

安装autoconf-archive

wget http://springdale.math.ias.edu/data/puias/computational/7/x86_64//autoconf-archive-2016.09.16-1.sdl7.noarch.rpm
rpm -i autoconf-archive-2016.09.16-1.sdl7.noarch.rpm

安装leptonica

wget http://www.leptonica.org/source/leptonica-1.74.4.tar.gz
tar zxvf leptonica-1.74.4.tar.gz
cd leptonica-1.74.4/
./configure
make
make install

安装C++11

这个需要增加一个yum的repo来进行安装

wget http://people.centos.org/tru/devtools-2/devtools-2.repo -O /etc/yum.repos.d/devtools-2.repo
yum install devtoolset-2-gcc devtoolset-2-binutils devtoolset-2-gcc-c++
ln -s /opt/rh/devtoolset-2/root/usr/bin/* /usr/local/bin/

这里要命的是http://people.centos.org/tru/非常慢,导致yum报错退出,可能需要翻墙才能搞掂

2.安装tesseract4

git clone https://github.com/tesseract-ocr/tesseract.git tesseract-ocr
cd tesseract-ocr
./autogen.sh
./configure PKG_CONFIG_PATH=/usr/local/lib/pkgconfig

PKG_CONFIG_PATH=/usr/local/lib/pkgconfig 如果没有配置这个路径,会提示错误

make
make install
ldconfig

3.语言包

tesseract默认只有eng的语言包,需要手动下载

语言包的目录是 /usr/local/share/tessdata

下载地址:https://github.com/tesseract-ocr/tesseract/wiki/Data-Files#data-files-for-version-400

如果觉得识别率比较低,可以使用经过训练的语言包,把语音包下载到下面的目录里面

mkdir /usr/local/share/tessdata_best

下载地址:https://github.com/tesseract-ocr/tessdata_best

测试

tesseract some.jpeg mytxt --tessdata-dir /usr/local/share/tessdata_best/ -l eng

你可能感兴趣的:(Centos 6.5上的Tesseract 4.0安装)