1. 在ubuntu下可以自动安装
- sudo apt-get install tesseract-ocr
2.编译安装
a.编译环境: gcc gcc-c++ make(这个环境一般机器都具备,可以忽略)
- yum install gcc gcc-c++ make
b.安装tesseract-ocr编译必须的包
- yum/apt-get install autoconf automake libtool
c.增加图像解析需要的包,可以按照指定的格式选择包
- yum install libjpeg-devel libpng-devel libtiff-devel zlib-devel
ubuntu
- sudo apt-get install libpng12-dev
- sudo apt-get install libjpeg62-dev
- sudo apt-get install libtiff4-dev
d.下载 leptonica 包: http://www.leptonica.org/source/leptonica-1.71.tar.gz
- wget http://www.leptonica.org/source/leptonica-1.71.tar.gz
- tar -zxvf ...
- ./configure
- make
- make install
需要注意,leptonica的版本问题
3.01 requires at least v1.67 of Leptonica.
3.02 requires at least v1.69 of Leptonica. (Both available in Ubuntu 12.04 Precise Pangolin.)
3.03 requires at least v1.70 of Leptonica. (Both available in Ubuntu 14.04 Trusty Tahr.)
如果版本不一致,会出现问题如下:
- Tesseract Open Source OCR Engine v3.02.02 with Leptonica
- Error in findTiffCompression: function not present
- Error in pixReadStreamTiff: function not present
- Error in pixReadStream: tiff: no pix returned
- Error in pixRead: pix not read
- Unsupported image type.
e.下载 tesseract-3.02 安装包: http://tesseract-ocr.googlecode.com/files/tesseract-3.02.02.tar.gz
- wget http://tesseract-ocr.googlecode.com/files/tesseract-ocr-3.02.02.tar.gz
- ./autogen.sh
- ./configure
- make
- make install
- ldconfig
f.下载 tesseract-3.02 英文语言包: http://tesseract-ocr.googlecode.com/files/tesseract-ocr-3.02.eng.tar.gz,解压后将 tesseract-ocr/tessdata 下的所有文件全部拷贝到 /usr/local/share/tessdata 下。
测试
- tesseract phototest.tif phototest -l eng
这时应该在当前目录生成一个 phototest.txt 文本文件,内容就是 phototest.tif 显示的文字.