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. CSS3中Transition屬性詳解以及示例分享2. ASP基礎(chǔ)入門第八篇(ASP內(nèi)建對象Application和Session)3. jsp文件下載功能實(shí)現(xiàn)代碼4. XMLHTTP資料5. asp.net core項(xiàng)目授權(quán)流程詳解6. html中的form不提交(排除)某些input 原創(chuàng)7. ASP常用日期格式化函數(shù) FormatDate()8. CSS3實(shí)現(xiàn)動態(tài)翻牌效果 仿百度貼吧3D翻牌一次動畫特效9. ASP動態(tài)網(wǎng)頁制作技術(shù)經(jīng)驗(yàn)分享10. 在JSP中使用formatNumber控制要顯示的小數(shù)位數(shù)方法
