contour_detection.py 文件源码

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

项目:pictureflow 作者: mentum 项目源码 文件源码
def apply(self, item, threshold):

        img = item.img_mat

        img[img > 0] = 255
        _, contours, _ = cv2.findContours(img, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)

        valid_contours = []

        for contour in contours:
            max_x = contour[:, :, 0].max()
            min_x = contour[:, :, 0].min()

            max_y = contour[:, :, 1].max()
            min_y = contour[:, :, 1].min()

            if (max_x - min_x) * (max_y - min_y) > threshold:
                valid_contours.append(contour)

        yield valid_contours
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号