def get_corners_from_contours(contours, corner_amount=4):
"""
Finds four corners from a list of points on the goal
epsilon - the minimum side length of the polygon generated by the corners
Parameters:
:param: `contours` - a numpy array of points (opencv contour) of the
points to get corners from
:param: `corner_amount` - the number of corners to find
"""
coefficient = .05
while True:
# print(contours)
epsilon = coefficient * cv2.arcLength(contours, True)
# epsilon =
# print("epsilon:", epsilon)
poly_approx = cv2.approxPolyDP(contours, epsilon, True)
hull = cv2.convexHull(poly_approx)
if len(hull) == corner_amount:
return hull
else:
if len(hull) > corner_amount:
coefficient += .01
else:
coefficient -= .01
vision_processing.py 文件源码
python
阅读 25
收藏 0
点赞 0
评论 0
评论列表
文章目录