基于python的视频车牌识别

2021-12-08 05:36:09 发布

您现在位置:Python中文网/ 问答频道 /正文

enter image description here我正在运行此代码,但它给出了一个错误,我正在尝试解决该错误。 给出了用python语言编写的视频车牌识别代码。你知道吗

给定的错误:-你知道吗

Traceback (most recent call last):   File "Main.py", line 16, in
<module>
     plate_Original, plate_morphEx, edge = preprocessOne(plateFrame, (42,10), True)   File
 "C:\Users\Admin\Desktop\Radar\pythonEdition\Modules\Basic.py", line
 11, in preprocessOne
     plateGray = enhance(cv2.cvtColor(plateFrame, cv2.COLOR_BGR2GRAY)) cv2.error: OpenCV(4.1.2)
 C:\projects\opencv-python\opencv\modules\imgproc\src\color.cpp:182:
 error: (-215:Assertion failed) !_src.empty() in function
 'cv::cvtColor'

在主.py:-

    plate_Original, plate_morphEx, edge = preprocessOne(plateFrame, (42,10), True)

在基本.py:-

def preprocessOne(plateFrame, se_shape, Show = False):
plateOrigin = copy.copy(plateFrame)
plateGray = enhance(cv2.cvtColor(plateFrame, cv2.COLOR_BGR2GRAY))
plateGaussian = cv2.GaussianBlur(plateGray, (5,5), 0)
plateSobel = cv2.Sobel(plateGaussian, -1, 1, 0)
h, plateThresh = cv2.threshold(plateSobel, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)

se = cv2.getStructuringElement(cv2.MORPH_RECT, se_shape)
plateMorphEx = cv2.morphologyEx(plateThresh, cv2.MORPH_CLOSE, se)
edge = np.copy(plateThresh)