简体   繁体   English

pyTesseract不从图像输出文本

[英]pyTesseract not outputing text from image

maybe someone could help me!也许有人可以帮助我! When I run the following code当我运行以下代码时

import pytesseract from pytesseract import image_to_string from PIL import Image import PIL从 pytesseract 导入 pytesseract 从 PIL 导入 image_to_string 导入图像导入 PIL

file = Image.open('/usr/local/Cellar/tesseract/4.1.0/share/tessdata/cap.png')
we_will = pytesseract.image_to_string(file)
print(we_will)

all that gets outputed is:输出的所有内容是:

Process finished with exit code 0

which is no help.这是没有帮助的。 What am I doing wrong?我究竟做错了什么?

Sounds like we_will is the empty string.听起来像we_will是空字符串。 Try printing repr(we_will) to understand this idea more clearly.尝试打印repr(we_will)以更清楚地理解这个想法。

IIRC, PyTesseract does this when it can't figure out what the text is inside the image. IIRC,PyTesseract 在无法弄清楚图像中的文本时会执行此操作。 You can get the best results for a cropped image with a single-color background.对于具有单色背景的裁剪图像,您可以获得最佳效果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM