首页 > 解决方案 > pyTesseract 不从图像输出文本

问题描述

也许有人可以帮助我!当我运行以下代码时

从 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)

输出的是:

Process finished with exit code 0

这没有帮助。我究竟做错了什么?

标签: pythonimage-processingtesseractpython-tesseract

解决方案


听起来像是we_will空字符串。尝试打印repr(we_will)以更清楚地理解这个想法。

IIRC,PyTesseract 在无法确定图像中的文本时会执行此操作。对于具有单色背景的裁剪图像,您可以获得最佳效果。


推荐阅读