Skip to content

Commit ab994f2

Browse files
committed
add color display window
1 parent 7004963 commit ab994f2

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

paintApplication.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@
55

66
draw = False
77
window_name = "Paint Brush Application"
8+
color_win_position = [(400, 30), (490,90)]
89
bgr_track = {'B': 0, 'G': 0, 'R': 0}
910

1011
img = np.zeros((512,512,3), np.uint8)
1112
cv2.namedWindow(window_name)
1213

14+
# Initial color window, showing black
15+
cv2.rectangle(img, color_win_position[0], color_win_position[1], (0,0,0), -1)
16+
1317
font = cv2.FONT_HERSHEY_SIMPLEX
1418
img = cv2.putText(img, "R: ", (10, 30), font, 0.5, (255,255,255), 1)
1519
img = cv2.putText(img, "G: ", (90, 30), font, 0.5, (255,255,255), 1)
@@ -73,4 +77,10 @@ def draw_circle(event, x, y, flags, param):
7377
key = cv2.waitKey(1) & 0xff
7478
if key==ord('q'):
7579
break
80+
81+
b = cv2.getTrackbarPos("B", window_name)
82+
g = cv2.getTrackbarPos("G", window_name)
83+
r = cv2.getTrackbarPos("R", window_name)
84+
cv2.rectangle(img, color_win_position[0], color_win_position[1], (b,g,r), -1)
85+
7686
cv2.destroyAllWindows()

0 commit comments

Comments
 (0)