python做簡單的圖像文字識別


python實現圖像文字識別,我們需要安裝 pytesseract 和 pillow 這兩個庫,直接用 pip 安裝就好。

其次還需要安裝 Tesseract-OCR.exe 這個軟件。

下面是實現代碼:

import pytesseract
from PIL import Image

pytesseract.pytesseract.tesseract_cmd = 'D://Python//Tesseract-OCR//tesseract.exe'//Tesseract-OCR安裝路徑
image = Image.open('D://3.png')//圖片路徑
text = pytesseract.image_to_string(image,lang='chi_sim')//chi_sim為中文包
print(text)

英文圖片演示:

 

 演示結果:

 

 中文圖片演示:

 

演示結果:

 

 

 

 

 

 

 


免責聲明!

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



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