python pytesseract库是什么
发布时间:2024-07-04 14:48:42

说明
1、pyteseract需要安装在本地的teseract-ocr.一起使用exe文件。
2、需要注意的是,安装时必须选择中文包,默认情况下只支持英文识别。
安装命令:
pipinstallpytesseract
实例
importpytesseract fromPILimportImage text=pytesseract.image_to_string(Image.open(r"d:\Desktop39DEE621-40EA-4ad1-90C-79EB5.png")) print(text)
输出识别结果:
UsingTesseractOCRwithPython
#importthenecessarypackages
fromPILimportImage
importpytesseract
importergperse
importcv2
importos
#constructtheargumentparseandparsethearguments
ap=argparse.ArgunentParser()
ap.add_argument("-i","--image",required-True,
help="pathtoinputimagetobeOCR'd")
ap.add_argument("-p","--preprocess",typesstr,default="thresh",
helpe"typeofpreprocessingtobedone")
args=vars(ap.parse_args())以上是python 介绍pyteseract库,希望对大家有所帮助。更多Python学习指导:python基础教程
本文教程操作环境:windows7系统Python 3.9.1,DELL G3电脑。
下一篇 python字典如何遍历数据
