【问题标题】:Problem in Using opencv and pytesseract for extracting text out of images in Python3.7 interpreterPython3.7解释器中使用opencv和pytesseract从图像中提取文本的问题
【发布时间】:2021-03-22 09:31:37
【问题描述】:

我打算使用 opencv 和 pytesseract 来提取图像中的文本。在 Python 3.7 解释器中执行以下代码时,我收到一个我不确定我是否理解的错误。

import cv2
import pytesseract
#tesseract.exe location provided 
pytesseract.tesseract_cmd=r'C:\\Users\\shree\\AppData\\Local\\Programs\\Tesseract-OCR\\tesseract.exe'
#image location provided
img=cv2.imread('C:\\Users\\shree\\Desktop\\hey.jpeg')
text=pytesseract.image_to_string(img)
print(text)

error shown

附注:

  1. 我已经安装了 opencv 和 pytessearct "C:\Users\shree\AppData\Local\Programs\Python\Python37-32\Scripts"
  2. Python 3.7 解释器安装在 "C:\Users\shree\AppData\Local\Programs\Python\Python37-32"
  3. 如果这是一个明显/愚蠢的问题,请原谅。实际上,我才刚刚开始。我在https://towardsdatascience.com/read-text-from-image-with-one-line-of-python-code-c22ede074cac读到了这个

非常感谢您提供详细的答案和替代方式(如果需要)。 谢谢!

【问题讨论】:

标签: python opencv text ocr python-tesseract


【解决方案1】:

换行,

pytesseract.tesseract_cmd=r'C:\\Users\\shree\\AppData\\Local\\Programs\\Tesseract-OCR\\tesseract.exe'

与,

pytesseract.pytesseract.tesseract_cmd = r'C:\\Users\\shree\\AppData\\Local\\Programs\\Tesseract-OCR\\tesseract.exe'

如果 tesseract 安装正确,这应该可以解决问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-07
    • 1970-01-01
    • 2020-06-15
    • 1970-01-01
    相关资源
    最近更新 更多