iis服务器助手广告广告
返回顶部
首页 > 资讯 > 后端开发 > Python >python pytesseract库的实例用法
  • 680
分享到

python pytesseract库的实例用法

pythonpytesseract库 2022-06-02 22:06:36 680人浏览 独家记忆

Python 官方文档:入门教程 => 点击学习

摘要

说明 pytesseract需要与安装在本地的tesseract-ocr.exe文件一起使用。 需要注意的是,安装时必须选择中文包,默认只支持英文识别。 安装命令 pip install pytesseract

说明

pytesseract需要与安装在本地的tesseract-ocr.exe文件一起使用。

需要注意的是,安装时必须选择中文包,默认只支持英文识别。

安装命令


pip install pytesseract

实例


import pytesseract
from PIL import Image
text = pytesseract.image_to_string(Image.open(r"d:\Desktop\39DEE621-40EA-4ad1-90CC-79EB51D39347.png"))
print(text)

识别结果输出


Using Tesseract OCR with python
# import the necessary packages
from PIL import Image
import pytesseract
import ergperse
import cv2
import os
 
# construct the argument parse and parse the arguments
ap = argparse.ArgunentParser()
ap.add_argument("-i", "--image", required-True,
help="path to input image to be OCR'd")
ap.add_argument("-p", "--preprocess", typesstr, default="thresh",
helpe"type of preprocessing to be done")
args = vars (ap.parse_args())

实例扩展:

Python使用pytesseract库识别图片文字

准备

首先需在本机安装Tesseract客户端,然后安装pytesseract库:


pip install pytesseract

没安装过PIL的也要安装一下,因为所调用的第一个参数是由Image类返回:


pip install PILLOW

实例


import pytesseract
from PIL import Image

img = Image.open("D://aa.jpg")
text = pytesseract.image_to_string(img, lang="chi_sim")
print(text)

到此这篇关于Python pytesseract库的实例用法的文章就介绍到这了,更多相关python pytesseract库是什么内容请搜索编程网以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程网!

--结束END--

本文标题: python pytesseract库的实例用法

本文链接: https://www.lsjlt.com/news/11122.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作