【发布时间】:2019-11-11 11:56:34
【问题描述】:
我想从车牌图像中读取字母和数字。我正在使用Python,并且我已经读到我可以使用pytesseract 来做到这一点。
我写了一个简单的代码,但我得到了一个错误:
raise TesseractNotFoundError()
pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it's not in your path
我不知道如何解决这个问题,这是我的代码:
import cv2
import pytesseract
img = cv2.imread('image.jpg')
cv2.imshow('original', img)
cv2.waitKey(0)
text = pytesseract.image_to_string(img, config='')
print("Detected Number is:", text)
这是图片:
我已经安装了 pytesseract。 当我运行这个时:
import importlib.util
print(importlib.util.find_spec('pytesseract'))
我明白了:
ModuleSpec(name='pytesseract', loader=<_frozen_importlib_external.SourceFileLoader object at 0x02F8F070>, origin='C:\\Users\\Pc\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\pytesseract\\__init__.py', submodule_search_locations=['C:\\Users\\Pc\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\pytesseract'])
【问题讨论】:
-
做一个
pip install pytesseract -
我已经这样做了
-
你是在windows机器上吗?
-
是的,我已经更新了问题,请检查一下
-
尝试像这样为 tesseract 添加路径,
pytesseract.pytesseract.tesseract_cmd = r'<full_path_to_your_tesseract_executable>'
标签: python opencv python-tesseract