-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrackbar.py
More file actions
31 lines (25 loc) · 717 Bytes
/
Copy pathtrackbar.py
File metadata and controls
31 lines (25 loc) · 717 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import cv2
import numpy as np
def nothing(x):
print(x)
img = np.zeros((300,512,3), np.uint8)
cv2.namedWindow('image')
cv2.createTrackbar('B', 'image', 0, 255, nothing)
cv2.createTrackbar('G', 'image', 0, 255, nothing)
cv2.createTrackbar('R', 'image', 0, 255, nothing)
switch = '0 : OFF\n 1 : ON'
cv2.createTrackbar(switch, 'image', 0, 1, nothing)
while(1):
cv2.imshow('image', img)
k = cv2.waitKey(1) & 0xFF
if k == 27:
break
b = cv2.getTrackbarPos('B', 'image')
g = cv2.getTrackbarPos('G', 'image')
r = cv2.getTrackbarPos('R', 'image')
s = cv2.getTrackbarPos(switch, 'image')
if s == 0:
img[:] = 0
else:
img[:] = [b, g, r]
cv2.destroyAllWindows()