【发布时间】:2023-03-02 21:27:01
【问题描述】:
我正在尝试使用带有 OpenCV 的 python 脚本来挑选图像中的车牌并返回坐标/在车牌周围绘制一个边界框。我编写的脚本无法找到车牌,它经常返回汽车的不同区域。
import numpy as np
import cv2
def find_license(image):
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
gray = cv2.bilateralFilter(gray, 11, 17, 17)
edged = cv2.Canny(gray, 30, 200)
cv2.imwrite('detect.png', edged)
(cnts, _) = cv2.findContours(edged.copy(), cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)
cnts=sorted(cnts, key = cv2.contourArea, reverse = True)[:20]
# loop over our contours
for c in cnts:
peri = cv2.arcLength(c, True)
approx = cv2.approxPolyDP(c, 0.02 * peri, True)
cv2.drawContours(image, [approx], -1, (0,255,0), 3)
# compute the bounding box of the of the paper region and return it
return cv2.minAreaRect(c)
【问题讨论】:
-
你能展示一个成功和失败图像的例子吗...?
标签: python opencv object-detection