【问题标题】:Error code list for Tesseract? 3221225781Tesseract 的错误代码列表? 3221225781
【发布时间】:2020-04-30 21:40:38
【问题描述】:

我正在试验 Pytesseract,但遇到了问题。我在 Windows 10 上运行 Python 3.8.2 和 Tesseract 4.0.0(也尝试使用 5.0.0 和 3.0.5,同样的错误)和 Pytesseract 0.3.4(安装了 pip)。我可以从 cmd 启动 tesseract,因为我按预期添加了路径变量。 png 图像实际上是 6 的屏幕截图。

代码很简单:

from PIL import Image
import pytesseract

img = Image.open('6.png')
print(pytesseract.image_to_string(img))

这是我得到的错误:

Traceback (most recent call last):
  File "C:\Documents\TestPytesseract\findNumber.py", line 5, in <module>
    print(pytesseract.image_to_string(img))
  File "C:\Users\ilita\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pytesseract\pytesseract.py", line 356, in image_to_string
    return {
  File "C:\Users\ilita\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pytesseract\pytesseract.py", line 359, in <lambda>
    Output.STRING: lambda: run_and_get_output(*args),
  File "C:\Users\ilita\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pytesseract\pytesseract.py", line 270, in run_and_get_output
    run_tesseract(**kwargs)
  File "C:\Users\ilita\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pytesseract\pytesseract.py", line 246, in run_tesseract
    raise TesseractError(proc.returncode, get_errors(error_string))
pytesseract.pytesseract.TesseractError: (3221225781, '')

找不到有关此错误代码的任何信息。欢迎任何帮助。

非常感谢。

【问题讨论】:

  • 你安装了 tesseract for windows 吗? github.com/tesseract-ocr/tesseract/wiki
  • 是的,我尝试使用 4.0.0、5.0.0 和 3.0.5。目前,4.0.0 已安装:C:\Users\ilita&gt;tesseract -v tesseract 4.00.00alpha leptonica-1.74.1 libgif 4.1.6(?) : libjpeg 8d (libjpeg-turbo 1.5.0) : libpng 1.6.20 : libtiff 4.0.6 : zlib 1.2.8 : libwebp 0.4.3 : libopenjp2 2.1.0
  • Windows 错误代码是出了名的可怕; answers.microsoft.com/en-us/windows/forum/…

标签: python ocr tesseract python-tesseract


【解决方案1】:

您可以尝试在您的 python 代码中设置 tesseract 命令

import pytesseract
# Set the path to Tesseract-OCR
pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract.exe'

此外,请确保您的 Windows 环境变量是否正确设置为您安装 Tesseract-OCR 的路径。对我来说,Tesseract-OCR 的路径是 C:\Program Files\Tesseract-OCR\,所以 PATH 包含

  • C:\Program Files\Tesseract-OCR\tessdata
  • C:\Program Files\Tesseract-OCR

并且你的环境变量中应该有另一个变量TESSDATA_PREFIX,并且应该设置为

  • C:\Program Files\Tesseract-OCR\tessdata

希望有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-06-26
    • 2017-01-28
    • 2014-06-21
    • 1970-01-01
    • 2020-06-06
    • 1970-01-01
    • 2012-10-14
    • 1970-01-01
    相关资源
    最近更新 更多