vision_processing.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:Stronghold-2016-Vision 作者: team4099 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号