File size: 376 Bytes
efb1801 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
import cv2
import time
cap = cv2.VideoCapture(0)
if not cap.isOpened():
print("Cannot open camera")
exit()
while True:
ret, frame = cap.read()
if ret:
cv2.imwrite('captured_frame.jpg', frame)
print("Frame captured and saved as captured_frame.jpg")
else:
print("Can't receive frame")
break
time.sleep(1)
cap.release() |