安裝Tesseract-OCR
準備工做:
編譯環境: gcc gcc-c++ make(這個環境通常機器都具有,能夠忽略)
yum install gcc gcc-c++ make
依賴的包: autoconf automake libtool libjpeg-devel libpng-devel libtiff-devel zlib-devel leptonica(1.67以上)html
1. autoconf automake libtool libjpeg-devel libpng-devel libtiff-devel zlib-devel 能夠經過yum安裝:
yum install autoconf automake libtool
yum install libjpeg-devel libpng-devel libtiff-devel zlib-devel
2. leptonica 須要源碼編譯安裝
參考資料:
http://paramountideas.com/tesseract-ocr-30-and-leptonica-installation-centos-55-and-opensuse-113
http://www.leptonica.org/source/README.html
下載 leptonica 包: http://www.leptonica.org/source/leptonica-1.68.tar.gz
解壓後切換到 leptonica-1.68 根目錄
./configure
make
make install
tesseract安裝:
依賴安裝完畢後開始安裝tesseract
下載 tesseract-3.01 安裝包: http://tesseract-ocr.googlecode.com/files/tesseract-3.01.tar.gz
解壓後切換到 tesseract-3.01 根目錄
(若是在make時遇到相似 strngs.h:1: error: stray '\357' in program 的錯誤,請將 tesseract-3.01/ccutil/strngs.h 文件轉爲 ANSI 編碼保存,再從新編譯)
./autogen.sh
./configure
make
make install
ldconfig
tesseract英文語言包安裝:
下載 tesseract-3.01 英文語言包: http://tesseract-ocr.googlecode.com/files/tesseract-ocr-3.01.eng.tar.gz
解壓後將 tesseract-ocr/tessdata 下的全部文件所有拷貝到 /usr/local/share/tessdata 下
安裝完畢.
測試一下:
切換到解壓後的 tesseract-3.01 根目錄(這個目錄下有一個自帶的 phototest.tif 能夠作測試用)
命令行:
tesseract phototest.tif phototest -l eng
輸出:
Tesseract Open Source OCR Engine v3.01 with Leptonica
Page 0
這時應該在當前目錄生成一個 phototest.txt 文本文件,內容就是 phototest.tif 顯示的文字.c++