python文字识别tesseract
安装python的pillow 和 tesseract两个包:pip install pytesseractpip install pillow运行下面的代码:import pytesseractfrom PIL import Imageimg = Image.open('text.jpg')#提前准备test.jpg,需要识别的图片文件text = pytesseract.image_to_st
·
安装python的pillow 和 tesseract两个包:
pip install pytesseract
pip install pillow
运行下面的代码:
import pytesseract
from PIL import Image
img = Image.open('text.jpg') #提前准备test.jpg,需要识别的图片文件
text = pytesseract.image_to_string(img)
print(text)
tesseract 命令行使用方法
安装 tesseract 此处下载
https://tesseract-ocr.github.io/tessdoc/#binaries
得到一个二进制安装文件。(另注意文字识别库)
注意在环境变量添加tesseract的路径。
tesseract 5.png stdout -l chi_sim
tessaeract命令的参数解释:
- 5.png----需要识别的文件
- stdout----存放识别后的文本(输出文件txt格式)
- -l chi-sim ----识别语言 简体中文
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐



所有评论(0)