Falafel.py 文件源码

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

项目:Millennium-Eye 作者: Elysium1937 项目源码 文件源码
def sizeFiltering(contours):
    #this function filters out the smaller retroreflector (as well as any noise) by size
    #_, contours, _ = cv2.findContours(img, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
    """blank_image = np.zeros((img.shape[0],img.shape[1],3), np.uint8)
    cv2.drawContours(blank_image, contours, -1, (255, 255, 255))
    cv2.imshow("imagia", blank_image)
    cv2.waitKey()"""
    if len(contours) == 0:
        print "errorrrrr"
        return 0
    big = contours[0]
    for c in contours:
        if type(c) and type(big) == np.ndarray:
            if cv2.contourArea(c) > cv2.contourArea(big):
                big = c
        else:
            print type(c) and type(big)
            return 0
    """blank_image = np.zeros((img.shape[0],img.shape[1],3), np.uint8)
    cv2.drawContours(blank_image, big, -1, (255, 255, 255))
    cv2.imshow("imagia", blank_image)
    cv2.waitKey()"""
    """blank_image = np.zeros((img.shape[0],img.shape[1],3), np.uint8)
    cv2.drawContours(blank_image, big, -1, (255, 255, 255))"""
    x,y,w,h = cv2.boundingRect(big)
    """cv2.rectangle(blank_image, (x,y), (x+w, y+h), (255,255,255))
    cv2.imshow("rect", blank_image)
    cv2.waitKey()"""
    return big
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号