网络编程
位置:首页>> 网络编程>> 网络编程>> 如何利用pytesseract识别图片中的数字

如何利用pytesseract识别图片中的数字

作者:Zhao-Jichao  发布时间:2023-07-11 12:48:36 

标签:pytesseract,识别图片,数字

用pytesseract识别图片中的数字

Win 平台

使用步骤

一、安装包。

二、找个图片,运行如下识别程序。

示例程序:

import pytesseract
from PIL import Image
if __name__ == '__main__':
   file = Image.open("test.bmp")
   text = pytesseract.image_to_string(file,lang="eng")
   print(text)

示例图片:

如何利用pytesseract识别图片中的数字

识别结果:

如何利用pytesseract识别图片中的数字

问题解决

有可能会出现如下错误提示:

tesseract is not installed or it’s not in your PATH. See README file for more information.

如何利用pytesseract识别图片中的数字

解决办法为

一、若没有安装 Tesseract-OCR 先下载安装,下载地址为:Tesseract-OCR。

然后记录好你的安装路径,下图展示的是默认路径。

如何利用pytesseract识别图片中的数字

二、之后找到 pytesseract.py 文件。我下图展示的同样还是默认路径。

如何利用pytesseract识别图片中的数字

三、打开 pytesseract.py 文件,在下图中展示的第 31 行左右的位置,替换路径为刚才 Tesseract-OCR 的安装路径。

如何利用pytesseract识别图片中的数字

之后返回再次运行识别程序就不会报错了。

来源:https://zhaojichao.blog.csdn.net/article/details/121627623

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com