【发布时间】:2016-06-21 10:37:20
【问题描述】:
我正在使用 Python 2.7 和 OpenCV 3.0。我正在做一个检测车牌的项目。
我现在正在检查轮廓的顶点数。如果有 4 个顶点(大约元素个数),那么它更有可能是 矩形/ 平行四边形/ 四边形。 p>
(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
for c in cnts:
peri = cv2.arcLength(c, True)
approx = cv2.approxPolyDP(c, 0.02 * peri, True)
if len(approx) == 4 and ratio(approx):
cv2.drawContours(image, [approx], -1, (0,255,0), 3)
我得到了两个带数组的四边形。
但是,您可以看到,有一个不规则多边形。这是数组:
[[[209 198]]
[[466 94]]
[[259 153]]
[[247 1]]]
我问的是如何省略不规则四边形。谢谢
【问题讨论】:
-
从我的头顶:计算Convex hull并将原始多边形与其凸包进行比较。如果它们不相似,则可能不是车牌。
标签: python image opencv image-processing polygon