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)
评论列表
文章目录