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