Skip to content

Commit cd661ea

Browse files
authored
Camera
1 parent 61a81c8 commit cd661ea

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

camera.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import cv2
2+
import random
3+
import time
4+
5+
6+
cap = cv2.VideoCapture(0)
7+
count = 0
8+
b = random.randint(1, 10000)
9+
while True:
10+
ret, img = cap.read()
11+
cv2.imshow("Camera", img)
12+
if not ret:
13+
break
14+
k = cv2.waitKey(50)
15+
if k % 256 == 27:
16+
print("Closing Camera")
17+
break
18+
19+
if k % 256 == 32:
20+
time.sleep(1)
21+
file = r'Pictures\img' + str(count) + str(b) + '.jpeg'
22+
cv2.imwrite(file, img)
23+
count += 1
24+
cap.release()
25+
cv2.destroyAllWindows()

0 commit comments

Comments
 (0)