|
5 | 5 |
|
6 | 6 | draw = False
|
7 | 7 | window_name = "Paint Brush Application"
|
| 8 | +color_win_position = [(400, 30), (490,90)] |
8 | 9 | bgr_track = {'B': 0, 'G': 0, 'R': 0}
|
9 | 10 |
|
10 | 11 | img = np.zeros((512,512,3), np.uint8)
|
11 | 12 | cv2.namedWindow(window_name)
|
12 | 13 |
|
| 14 | +# Initial color window, showing black |
| 15 | +cv2.rectangle(img, color_win_position[0], color_win_position[1], (0,0,0), -1) |
| 16 | + |
13 | 17 | font = cv2.FONT_HERSHEY_SIMPLEX
|
14 | 18 | img = cv2.putText(img, "R: ", (10, 30), font, 0.5, (255,255,255), 1)
|
15 | 19 | 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):
|
73 | 77 | key = cv2.waitKey(1) & 0xff
|
74 | 78 | if key==ord('q'):
|
75 | 79 | 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 | + |
76 | 86 | cv2.destroyAllWindows()
|
0 commit comments