【问题标题】:Why pytesseract can't handle OSD mode?为什么 pytesseract 不能处理 OSD 模式?
【发布时间】:2021-04-09 09:44:23
【问题描述】:

我无法在 Ubuntu 上的 docker 映像上的 pytesseract 中运行 OSD 模式。在 Windows 上,此命令的作用类似于魅力:

pytesseract.image_to_osd(image)

但是在 docker 镜像中,它会导致以下错误。我想要实现的是使用 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 它不起作用。

标签: python ocr tesseract python-tesseract


【解决方案1】:

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

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-01-18
    • 1970-01-01
    • 2011-01-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-01
    相关资源
    最近更新 更多