-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmicroscope4.py
More file actions
31 lines (24 loc) · 753 Bytes
/
microscope4.py
File metadata and controls
31 lines (24 loc) · 753 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
import cv2 as cv
import numpy as np
import time
cap = cv.VideoCapture(0) # open webcam for capture
img_counter = 1
i=1
while True:
ret, frame = cap.read() # Take each frame
cv.imshow('live_feed',frame)
k = cv.waitKey(5) & 0xFF
if k%256 == 27:
print("Escape hit, closing...")
break
elif k%256 == 32:
while i<=10:
img_name ="images/frame5_{}.jpg".format(img_counter)
cv.imwrite(img_name, frame)
print("{} written!".format(img_name))
img_counter += 1
i=i+1
time.sleep(0.5)
cap.release() # Release the webcam
cv.destroyAllWindows()# Destroy all the windows
#time.sleep(1)