Python pytesseract驗(yàn)證碼識別庫用法解析
環(huán)境 centos7 python3
pytesseract只是tesseract-ocr的一種實(shí)現(xiàn)接口。所以要先安裝tesseract-ocr(大名鼎鼎的開源的OCR識別引擎)。
依賴安裝
yum install-y automake autoconf libtool gcc gcc-c++yum install-y libpng-devel libjpeg-devel libtiff-devel giflib-devel
安裝依賴的leptonica庫
wget http://www.leptonica.com/source/leptonica-1.72.tar.gz tar -xzvf leptonica-1.72.tar.gz cd leptonica-1.72./configuremake && make install
安裝tesseract-ocr
wget https://github.com/tesseract-ocr/tesseract/archive/3.04.00.tar.gzmv 3.04.00 Tesseract3.04.00.tar.gztar -xvf Tesseract3.04.00.tar.gz cd tesseract-3.04.00/./configuremake && make install
安裝語言包:
wget https://github.com/tesseract-ocr/tessdata/raw/master/eng.traineddata #英文默認(rèn)包wget https://github.com/tesseract-ocr/tessdata/raw/master/chi_sim.traineddata #中文繁體wget https://github.com/tesseract-ocr/tessdata/raw/master/chi_tra.traineddata #中文簡體cp/mv *.traineddata /usr/local/share/tessdata/ #移動下載的包到/usr/local/share/tessdata/ 這個(gè)路徑下,也可以手動移動
安裝pytesseract:
pip install Pillowpip install pytesseract
至此安裝完成,附上使用方法:
import pytesseract from PIL import Imagimage = Image.open('port_img.jpg')text = pytesseract.image_to_string(image)print(text)
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. 基于 Python 實(shí)踐感知器分類算法2. Python如何批量生成和調(diào)用變量3. ASP.Net Core對USB攝像頭進(jìn)行截圖4. ASP.NET MVC實(shí)現(xiàn)橫向展示購物車5. Python 中如何使用 virtualenv 管理虛擬環(huán)境6. Python獲取B站粉絲數(shù)的示例代碼7. python利用opencv實(shí)現(xiàn)顏色檢測8. windows服務(wù)器使用IIS時(shí)thinkphp搜索中文無效問題9. ASP.Net Core(C#)創(chuàng)建Web站點(diǎn)的實(shí)現(xiàn)10. 通過CSS數(shù)學(xué)函數(shù)實(shí)現(xiàn)動畫特效
