-
安装依赖包
yum install gcc gcc-c++ make
yum install autoconf automake libtool
yum install libjpeg-devel libpng-devel libtiff-devel zlib-devel
源码安装leptonica
下载
解压
tar xf leptonica-1.72.tar.gz
./configure && make && sudo make install
2. 源码安装Tesseract
1)下载
wget https://github.com/tesseract-ocr/tesseract/archive/master.zip
2)安装
./autogen.sh
configure && make && make install
ldconfig
3) 设置环境变量
cd
vi .bashrc
#在最后添加
export TESSDATA_PREFIX=/usr/local/share
source .bashrc #使之生效
3) 下载tessdata
git clone https://github.com/tesseract-ocr/tessdata.git
# 把训练好的数据给放到tessdata中
cp tessdata /usr/local/share -R
3. 测试
cd /root/tesseract-master/testing
tesseract phototest.tif phototest -l eng
[root@SZB-L0006409 testing]# pwd
/root/tesseract-master/testing
[root@SZB-L0006409 testing]# tesseract phototest.tif phototest -l eng
Tesseract Open Source OCR Engine v3.05.00dev with Leptonica
Page 1
Warning in pixReadMemTiff: tiff page 1 not found
5. 安装pytesseract
pip install pytesseract
from PIL import Image
import pytesseract
print pytesseract.image_to_string(Image.open('2ca28b68994436891d3b99a3612aa87c.jpg'))