-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrac_art.py
More file actions
37 lines (25 loc) · 766 Bytes
/
trac_art.py
File metadata and controls
37 lines (25 loc) · 766 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
32
33
34
35
36
37
import numpy as np
import cv2 as cv
def print_callback(x):
print(x)
# creater a black image, a window
# img = np.zeros((300, 521, 3), np.uint8)
cv.namedWindow('image')
cv.createTrackbar('CP', 'image', 10, 400, print_callback)
switch = 'color/gray'
cv.createTrackbar(switch, 'image', 0, 1, print_callback)
while True:
img = cv.imread('lena.jpg')
pos = cv.getTrackbarPos('CP', 'image')
font = cv.FONT_HERSHEY_SIMPLEX
cv.putText(img, str(pos), (150, 150), font, 4, (0, 255, 255) )
k = cv.waitKey(1) & 0xff
if k == 27:
break
s = cv.getTrackbarPos(switch, 'image')
if s == 0:
pass
else:
img = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
cv.imshow('image', img)
cv.destroyAllWindows()