注意:下面的下載網址和版本有更新的以最新的為准
1. 在ubuntu下可以自動安裝
[html] view plain copy
sudo apt-get install tesseract-ocr
2.編譯安裝
a.編譯環境: gcc gcc-c++ make(這個環境一般機器都具備,可以忽略)
[html] view plain copy
yum install gcc gcc-c++ make
b.安裝tesseract-ocr編譯必須的包
[html] view plain copy
yum/apt-get install autoconf automake libtool
c.增加圖像解析需要的包,可以按照指定的格式選擇包
[html] view plain copy
yum install libjpeg-devel libpng-devel libtiff-devel zlib-devel
ubuntu
[html] view plain copy
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
[html] view plain copy
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.)
如果版本不一致,會出現問題如下:
[html] view plain copy
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
[html] view plain copy
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 下。
測試
[html] view plain copy
tesseract phototest.tif phototest -l eng 這時應該在當前目錄生成一個 phototest.txt 文本文件,內容就是 phototest.tif 顯示的文字.