2
我正在使用Python和Opencv。我正在做一个项目来识别汽车摄像头的车牌。车牌照检测车牌摄像头
我试过使用Canny()
,但我仍然无法识别板。
1)
首先,我将图像转换为灰度,增加颜色的合同并最终将其转换成 “一柄图像”
img = cv2.imread("plate.jpg")
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
gray = cv2.equalizeHist(gray)
edged = cv2.Canny(gray, 200, 255)
2)
然后,我试图找到一个矩形轮廓如下,我试图通过convexHull()
滤除由面积和长度以及不规则多边形的不相干矩形:
(cnts, _) = cv2.findContours(edged.copy(), cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)
cnts=sorted(cnts, key = cv2.contourArea, reverse = True)[:10]
# loop over our contours
plate_candidates = []
for c in cnts:
peri = cv2.arcLength(c, True)
approx = cv2.approxPolyDP(c, 0.02 * peri, True)
area = cv2.contourArea(approx)
if len(approx) == 4 and area <=1000 and area >=500 and self._length_checking(approx):
hull = cv2.convexHull(approx,returnPoints = True)
if len(hull) ==4:
plate_candidates.append(approx)
cv2.drawContours(show, [approx], -1, (0,255,0), 3)
但是,我仍然无法辨认板子。我正在寻找帮助,我如何检测车牌。谢谢。
感谢您的回复。你的意思是我使用的限制太严格了吗?通过使用'area'和'rectangleness'就足以检测矩形? – VICTOR
在你的情况下,你甚至不需要矩形,你可以使用区域 – maxymoo
我以前使用过这种方法,但是,有时我会检测到一些非四边形的形状。为了过滤掉这些非四边形或不规则形状,我使用'len(hull)== 4'来确定 – VICTOR