python读取图片中的文字

it2023-04-08  80

通过一个脚本文件读取图片中的文字

step1 下载需要的文件

1.Tesseract的安装: https://digi.bib.uni-mannheim.de/tesseract/。选择合适的版本下载 2.添加环境变量path:C:\Program Files\Tesseract-OCR(自行调整安装目录)! 3.下载中文简体语言包: https://tesseract-ocr.github.io/tessdoc/Data-Files 4.下载相应的依赖:pip install pytesseract , pip install pillow 5.脚本程序

step2 运行脚本文件

# -*- coding: utf-8 -*- from PIL import Image import pytesseract text=pytesseract.image_to_string(Image.open('show.jpg'),lang='chi_sim') #识别中文 print(text)

大功告成! 识别效果和图片分辨率有关,最后需要再人工校正一遍。

参考:https://www.jb51.net/article/187678.htm

最新回复(0)