-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmouse_call.py
61 lines (52 loc) · 1.5 KB
/
mouse_call.py
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import cv2
img = cv2.imread(r"D:\computer_vision\data\flower.jpeg")
run =False
def draw_circle(event, x, y, flags, param):
global run
if event == cv2.EVENT_LBUTTONDOWN:
run=True
cv2.circle(img, (x, y), 20, (0, 255, 0), -1)
if event == cv2.EVENT_LBUTTONUP:
run = False
if event == cv2.EVENT_MOUSEMOVE:
if run==True:
cv2.circle(img, (x, y), 20, (255, 0, 0), -1)
cv2.namedWindow("Window")
cv2.setMouseCallback("Window", draw_circle)
while True:
cv2.imshow("Window", img)
k = cv2.waitKey(1)
if k == ord('c'):
img = cv2.imread(r"D:\computer_vision\data\flower.jpeg")
if k == 27:
cv2.destroyAllWindows()
break
# import cv2
#
# img = cv2.imread(r"D:\computer_vision\data\flower.jpeg")
# run = False
#
# def draw_circle(event, x, y,flags, param):
# global run
# if event == cv2.EVENT_LBUTTONDOWN:
# run = True
# print("hello")
# cv2.circle(img, (x, y), 20, (0, 255, 0), -1)
# elif event == cv2.EVENT_MOUSEMOVE:
# if run == True:
# cv2.circle(img, (x, y), 20, (0, 255, 0), -1)
#
#
#
# cv2.namedWindow(winname="Window")
# cv2.setMouseCallback("Window", draw_circle)
#
# while True:
# cv2.imshow("Window", img)
# k = cv2.waitKey(1)
# if k == ord('c'):
# img = cv2.imread(r"D:\computer_vision\data\flower.jpeg")
# if k == 27:
# cv2.destroyAllWindows()
# break
# cv2.destroyAllWindows()