Centos上安裝tesseract+pytesseract用來做圖片驗證碼的識別


轉載請注明出處:http://www.cnblogs.com/blazer/p/7131202.html

環境:Centos6.7

tesseract-3.05

pytesseract-0.1.7

Imaging-1.1.7

Ubuntu

If they are not already installed, you need the following libraries (Ubuntu 16.04/14.04):

sudo apt-get install g++ # or clang++ (presumably)
sudo apt-get install autoconf automake libtool
sudo apt-get install autoconf-archive
sudo apt-get install pkg-config
sudo apt-get install libpng12-dev
sudo apt-get install libjpeg8-dev
sudo apt-get install libtiff5-dev
sudo apt-get install zlib1g-dev

if you plan to install the training tools, you also need the following libraries:

sudo apt-get install libicu-dev
sudo apt-get install libpango1.0-dev
sudo apt-get install libcairo2-dev

官方叫你裝的依賴包

如果是用yum裝,則有些關鍵字不太一樣,需要慢慢裝。

 

都安裝完了之后,然后使用如下python

image = Image.open('yzm.jpeg')
vcode = pytesseract.image_to_string(image)

 

有可能會報以下錯誤:

IOError: decoder jpeg not available

 

 

那么,重裝Imaging-1.1.7

裝的時候可能會遇到一個問題。

python selftest.py

 執行該腳本能看到是否支持圖片

我的Centos中是已經安裝了libjpeg-turbo這個包的。

但是支持該腳本還是有如下關鍵字

*** TKINTER support not installed
*** JPEG support not installed
*** ZLIB (PNG/ZIP) support not installed
*** FREETYPE2 support not installed
*** LITTLECMS support not installed 

 那么

TCL_ROOT = None
JPEG_ROOT = None
ZLIB_ROOT = None
TIFF_ROOT = None
FREETYPE_ROOT = None
LCMS_ROOT = None 

 

改成

TCL_ROOT = "/usr/lib64/"
JPEG_ROOT = "/usr/lib64/"
ZLIB_ROOT = "/usr/lib64/"
TIFF_ROOT = "/usr/lib64/"
FREETYPE_ROOT = "/usr/lib64/"
LCMS_ROOT = "/usr/lib64/"

 

然后需要重新編譯和安裝

python2.7 setup.py clean
python2.7 setup.py build_ext
python2.7 setup.py build
python2.7 setup.py install

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM