pillow、pytesseract-ocr、pytesseract的安装和中文的识别
安装pytesseract库,必须先安装其依赖的PIL及tesseract-ocr,其中PIL为图像处理库,而后面的tesseract-ocr则为google的ocr识别引擎。一、安装PIL(换源)pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pillow二、安装Tesseract-OCR它的git:https://git...
安装pytesseract库,必须先安装其依赖的PIL及tesseract-ocr,其中PIL为图像处理库,而后面的tesseract-ocr则为google的ocr识别引擎。
一、安装PIL(换源)
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pillow
二、安装Tesseract-OCR
它的git:https://github.com/tesseract-ocr/tesseract
直接下载地址:https://digi.bib.uni-mannheim.de/tesseract/
找的最新版本:

我添加了math 跟chinese(因为是国内网络的原因吧,下载都失败,所以不用选择,后面自己下载后,添加到相应目录就好)

安装后需要配置环境变量



在cmd下测试tesseract -v
三、安装pytesseract(换源)
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pytesseract
重新开机后测试

importpytesseract
fromPILimportImage
image=Image.open("G:\\Python\\1.png")
print(image)
vcode=pytesseract.image_to_string(image)
print(vcode)
添加中文的识别库
github:
https://github.com/tesseract-ocr
第一个就好
将下载的.traineddata放到这个安装的这个目录下:


测试带代码
import pytesseract
from PIL import Image
image = Image.open("G:\\Python\\ch_sim.png")
print (image)
vcode = pytesseract.image_to_string(image, lang='chi_sim')
print (vcode)
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐

所有评论(0)