logoSet.py 文件源码

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

项目:vehicle_brand_classification_CNN 作者: nanoc812 项目源码 文件源码
def imgSeg_contour(img, b,g,r, per):
    lower = np.array([0, 0, 0])
    upper = np.array([b,g,r])
    shapeMask = cv2.inRange(img, lower, upper)

    #http://stackoverflow.com/questions/27746089/python-computer-vision-contours-too-many-values-to-unpack
    _, cnts, hierarchy = cv2.findContours(shapeMask.copy(), cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
    cnts = sorted(cnts, key = cv2.contourArea, reverse = True)[:4]

    for c in cnts:
        peri = cv2.arcLength(c, True)
        approx = cv2.approxPolyDP(c, per * peri, True) ### 0.04 ###
        if (len(approx) >= 4) and (len(approx) < 6):
            break
    return approx
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号