color_segment.py 文件源码

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

项目:cv_build18 作者: eknight7 项目源码 文件源码
def print_hsv(x):
    if x == 1:
        H_low = cv2.getTrackbarPos("H_low", "Segmented")
        S_low = cv2.getTrackbarPos("S_low", "Segmented")
        V_low = cv2.getTrackbarPos("V_low", "Segmented")
        H_high = cv2.getTrackbarPos("H_high", "Segmented")
        S_high = cv2.getTrackbarPos("S_high", "Segmented")
        V_high = cv2.getTrackbarPos("V_high", "Segmented")

        low = np.array([H_low, S_low, V_low])
        high = np.array([H_high, S_high, V_high])
        print "HSV Low: ", low, ", High: ", high

        save_name = 'seg' + '_lh_' + str(low[0]) + '_ls_' + str(low[1]) + '_lv_' + str(low[2]) \
                    + '_hh_' + str(high[0]) + '_hs_' + str(high[1]) + '_hv_' + str(high[2]) \
                    + '_' + img_str

        mask = cv2.inRange(birdsHSV, low, high)
        result = cv2.bitwise_and(birdsImg, birdsImg, mask = mask)
        res_name = '../results/' + save_name
        print "Saving result as", res_name
        cv2.imwrite(res_name, result)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号