detect.py 文件源码

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

项目:remho 作者: teamresistance 项目源码 文件源码
def solidity(contour, hull=None, area_min=0):
        """
        Calculate the solidity of a contour, which is the ratio of its area to the
        area of its convex hull.

        :param contour: the target contour
        :param hull: the convex hull of the contour, see cv2.convexHull(contour)
        :param area_min: a contour with an area below the minimum has a solidity of 0
        """
        if hull is None:
            hull = cv2.convexHull(contour)
        try:
            contour_area = cv2.contourArea(contour)
            hull_area = cv2.contourArea(hull)
            return contour_area / hull_area if hull_area > area_min else 0
        except ArithmeticError:
            return 0
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号