python pytesseract——3步識別驗證碼的識別入門


驗證碼識別是個大工程,但入門開始只要3步。需要用到的庫PIL、pytesserac,沒有的話pip安裝。還有一個是tesseract-ocr 下載地址:https://sourceforge.net/projects/tesseract-ocr-alt/files/。

哪3步?

 

1、安裝庫

pip install Pillow
pip install pytesseract

 

2、安裝tesseract-ocr

默認安裝,主要是新添加個環境變量。如下圖

 

3、編寫代碼

import pytesseract 
from PIL import Image
print pytesseract.image_to_string(Image.open("D:\\Desktop\\1.png"),lang="eng",config="-psm 7")

 

舉個例子,上圖的識別

 

 

bingo,7572!

 


免責聲明!

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



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