【发布时间】: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)
附注:
- 我已经安装了 opencv 和 pytessearct "C:\Users\shree\AppData\Local\Programs\Python\Python37-32\Scripts"
- Python 3.7 解释器安装在 "C:\Users\shree\AppData\Local\Programs\Python\Python37-32"
- 如果这是一个明显/愚蠢的问题,请原谅。实际上,我才刚刚开始。我在https://towardsdatascience.com/read-text-from-image-with-one-line-of-python-code-c22ede074cac读到了这个
非常感谢您提供详细的答案和替代方式(如果需要)。 谢谢!
【问题讨论】:
-
我觉得你也需要安装tesseract工具github.com/tesseract-ocr/tesseract
标签: python opencv text ocr python-tesseract