我想尝试 doctr (https://github.com/mindee/doctr),但决定切换回 pytesseract。
现在下面的代码不仅仅返回从示例图像中提取的字符串,而是告诉我不支持打印 pytesseract.image_to_string 的结果,因为
“ocr_predictor 返回具有嵌套结构的 Document 对象 (带有页面、块、线、字、人工制品)。”
:
from PIL import Image
import pytesseract
pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract.exe'
testImg = Image.open(r'images\test.png')
text = pytesseract.image_to_string(testImg)
print(text)
OCR 预测器?这是 doctr 发来的,对吗? 为什么要尝试使用它?考虑到我只导入 pytesseract,这怎么可能? 我尝试卸载 doctr 以及 tensorflow。这没有帮助,所以我手动删除了所有站点包。相同的结果。我删除了所有 python 版本并重新安装了 3.12 - 仍然没有变化。
我认为这可能是一些微不足道的事情,我根本不明白,因为我缺乏背景。
有什么想法吗?
我尝试创建和使用虚拟环境(我通常不这样做),但它仍然没有帮助。
事实证明有一个荒谬的解释我不想分享。这对其他人没有任何帮助。 ;)
已关闭。