gpt4 book ai didi

python - 为什么 pytesseract 不能处理 OSD 模式?

转载 作者:行者123 更新时间:2023-12-05 06:47:37 26 4
gpt4 key购买 nike

我无法在 Ubuntu 上的 docker 镜像上的 pytesseract 中运行 OSD 模式。在 Windows 上,这个命令就像魅力一样:

pytesseract.image_to_osd(image)

但在 docker image 中,它会导致以下错误。我想要实现的是使用 OSD 读取旋转信息。

File "/usr/local/lib/python3.9/site-packages/pytesseract/pytesseract.py", line 263, in run_tesseract
raise TesseractError(proc.returncode, get_errors(error_string))pytesseract.pytesseract.TesseractError: (1, 'Tesseract Open Source OCR Engine v5.0.0-alpha-20210401 with Leptonica UZN file /tmp/tess__cujlspf loaded. Estimating resolution as 169 UZN file /tmp/tess__cujlspf loaded. Warning. Invalid resolution 0 dpi. Using 70 instead. Too few characters. Skipping this page Error during processing.')

Tesseract 已正确安装,因为所有其他方法(如 image_to_string)均正常工作。令人惊讶的是,当我直接从终端调用 OSD 时,它起作用了

tesseract /images/1.jpg  output --psm 0
# cat output.osd
Page number: 0
Orientation in degrees: 0
Rotate: 0
Orientation confidence: 5.69
Script: Cyrillic
Script confidence: 0.10

Pytesseract 中是否存在错误或有任何解决方法?旋转信息不包含在任何其他 Tesseract 方法中,仅包含在此 OSD 中。非常感谢

最佳答案

我通过将配置参数添加到方法调用中找到了解决方案:

pytesseract.image_to_osd(file_name,config='--psm 0 -c min_characters_to_try=5')

这解决了错误,我可以获得角度数据。

关于python - 为什么 pytesseract 不能处理 OSD 模式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67018785/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com