简体   繁体   English

使用python从视频中识别车牌

[英]Car plate recognition from video using python

enter image description here I am running this code but it has given an error which I am trying to solve.在此处输入图像描述我正在运行此代码,但它给出了我正在尝试解决的错误。 The given code is of car plate recognition from video written in python.给定的代码是从用python编写的视频中识别车牌的。

The given error:-给定的错误:-

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'

In Main.py:-在 Main.py 中:-

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

In Basic.py:-在 Basic.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)

src.empty() in function cv::cvtColor usually means that the input file is missing.函数cv::cvtColor src.empty()通常意味着输入文件丢失。 Check the path and content of the video file.检查视频文件的路径和内容。 Or maybe there is a problem with plateFrame in main.py .或者也许 main.py 中的main.py有问题。 Try printing plateFrame and its shape.尝试印版框架及其形状。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM