[使用pytesseract打印“ image_to_string”的输出时,我得到一个空字符串。不确定为什么

问题描述 投票:1回答:1

这是我的代码。

import pytesseract
from PIL import Image
pytesseract.pytesseract.tesseract_cmd = r"C:\Program Files (x86)\Tesseract-OCR\tesseract.exe"
im = Image.open(file location)
print(im)
text = pytesseract.image_to_string(im)
print(text)

输出: PIL.PngImagePlugin.PngImageFile图像模式= RGBA大小= 680x680在0x11B17380E48>] >>

因此,我的图像正在打印,但是当使用函数image_to_string时,仅打印空白字符串。没有错误消息,所以我不确定我在做什么错。

这是我正在使用的图像。

screenshot

这是我的代码。从PIL导入pytesseract导入图像pytesseract.pytesseract.tesseract_cmd = r“ C:\ Program Files(x86)\ Tesseract-OCR \ tesseract.exe” im = Image.open(文件位置)print(im)文本= ...] >

python python-3.x ocr python-tesseract pytesser
1个回答
0
投票

要显示图像,您需要使用im.show(),并且要检测文本,请尝试使用计算机字体而不是您自己的笔迹(未经培训的笔迹。

© www.soinside.com 2019 - 2024. All rights reserved.