RGB
cv2.namedWindow('window')
fill_val = np.array([0, 0, 0], np.uint8)
def trackbar_callback(idx, value):
fill_val[idx] = value
cv2.createTrackbar('R','window', 255, 255, lambda v: trackbar_callback(2, v))
cv2.createTrackbar('G','window', 255, 255, lambda v: trackbar_callback(1, v))
cv2.createTrackbar('B','window', 255, 255, lambda v: trackbar_callback(0, v))
while True:
image = np.full((500, 500, 3), fill_val)
cv2.imshow('window', image)
key = cv2.waitKey(3)
if key == 27:
break
cv2.destroyAllWindows()
HSV
cv2.namedWindow('window')
fill_val = np.array([0, 0, 0], np.uint8)
def trackbar_callback(idx, value):
fill_val[idx] = value
cv2.createTrackbar('H','window', 0, 180, lambda v: trackbar_callback(0, v))
cv2.createTrackbar('S','window', 0, 255, lambda v: trackbar_callback(1, v))
cv2.createTrackbar('V','window', 0, 255, lambda v: trackbar_callback(2, v))
while True:
hsv_image = cv2.cvtColor(np.full((500, 500, 3), fill_val) ,cv2.COLOR_BGR2HSV)
cv2.imshow('window', hsv_image)
key = cv2.waitKey(3)
if key == 27:
break
cv2.destroyAllWindows()
Немає коментарів:
Дописати коментар