1. 程式人生 > >linux (CentOS)安裝python-tesseract 用於驗證碼識別

linux (CentOS)安裝python-tesseract 用於驗證碼識別

python-tesseract 是 tesseract的python封裝庫,能夠用於驗證碼的識別。尤其是可以通過更改識別庫的名稱達到使用自己訓練出來的庫的目的,尤為方便。關於如何訓練tesseract-ocr 的識別庫見 我的另一篇博文。

下面是官方版安裝python-tesseract 在CentOS6.5測試成功。

【官方安裝python-tesseract】

yum groupinstall "Development Tools" -y yum -y install wget cmake  yum -y install libjpeg-devel libpng-devel libtiff-devel zlib-devel 

yum -y install gcc gcc-c++ make numpy wget http://www.leptonica.com/source/leptonica-1.71.tar.gz tar zxvf leptonica-1.70.tar.gz cd leptonica-1.70 ./configure --prefix=/usr make make install cd .. wget http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.3/OpenCV-2.4.3.tar.bz2 tar jxvf OpenCV-2.4.3.tar.bz2 
cd OpenCV-2.4.3 cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr -D BUILD_PYTHON_SUPPORT=ON . make make install cd .. #svn checkout http://tesseract-ocr.googlecode.com/svn/trunk/ tesseract-ocr #wget https://tesseract-ocr.googlecode.com/files/tesseract-ocr-3.02.02.tar.gz #tar zxvf tesseract-ocr-3.02.02.tar.gzcd tesseract-ocr/ 
wget https://tesseract-ocr.googlecode.com/archive/3.03-rc1.tar.gz tar zxvf tesseract-ocr-3.03-rc1.tar.gz cd tesseract-ocr /autogen.sh ./configure --prefix=/usr make make install cp tessdata/eng* /usr/share/tessdata cd .. wget http://peak.telecommunity.com/dist/ez_setup.py python ez_setup.py  easy_install pip yum install python-devel -y svn checkout http://python-tesseract.googlecode.com/svn/trunk/ python-tesseract cd python-tesseract python setup.py build python setup.py install cd test-slim rm *.pyc rm *.pyd python test.py

【坑】

    以最終安裝目的去搜索資料吧。像python-tesseract 需要安裝opencv和numpy,而安裝opencv並不能通過pip install去安裝,單獨安裝的時候你會發現網上的資料特別雜,尤為本身opencv就是就是一個大工程,本身就是就一個大課題,所以不太的運用背景往往就導致別人能夠安裝成功而你不行。所以,效率最高的還是到官網找到安裝說明,特別是瞭解清楚需哪些依賴庫。