-
Notifications
You must be signed in to change notification settings - Fork 1
/
picture-old.py
60 lines (44 loc) · 904 Bytes
/
picture-old.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
import cv2
cam = cv2.VideoCapture(0)
cv2.namedWindow("test")
img_counter = 0
start = False;
end = False;
def takePictureAccessor():
global start
start = True
def haltCam():
global end
end = True
def takePicture():
global img_counter
img_name = "opencv_frame_{}.jpg".format(img_counter)
cv2.imwrite(img_name, frame)
print("{} written!".format(img_name))
img_counter += 1
def camOn():
global start
global end
while True:
ret, frame = cam.read()
cv2.imshow("test", frame)
if not ret:
break
cv2.waitKey(30)
if end:
# ESC pressed
print("Escape hit, closing...")
cam.release()
cv2.destroyAllWindows()
break
elif start:
takePicture(img_counter)
break
def cameraOn():
ret, frame = cam.read()
cv2.imshow("test", frame)
#if not ret:
# break
takePicture()
cam.release()
cv2.destroyAllWindows()