[英]Problem in Using opencv and pytesseract for extracting text out of images in Python3.7 interpreter
I intend to use opencv and pytesseract to extract text of out images.我打算使用 opencv 和 pytesseract 来提取图像中的文本。 On executing the following code in a Python 3.7 Interpreter, I am receiving a error I'm not sure I understand.
在 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)
PS: PS:
A Detailed answer and an alternate way(if required) would be highly appreciated.非常感谢您提供详细的答案和替代方式(如果需要)。 Thanks!
谢谢!
Replace the line,换线,
pytesseract.tesseract_cmd=r'C:\\Users\\shree\\AppData\\Local\\Programs\\Tesseract-OCR\\tesseract.exe'
with,和,
pytesseract.pytesseract.tesseract_cmd = r'C:\\Users\\shree\\AppData\\Local\\Programs\\Tesseract-OCR\\tesseract.exe'
This should fix the issue if tesseract is installed properly.如果 tesseract 安装正确,这应该可以解决问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.