Files
CommonCode/takeSnapshot.py
2025-09-04 22:48:15 -04:00

38 lines
1.3 KiB
Python
Executable File

import os
from datetime import datetime, timedelta
import cv2
import time
while True:
cdate = datetime.now()
try:
base_path = cdate.strftime('/home/thebears/Videos/Winslow/%Y%m%d/snapshots/')
prestr = base_path + cdate.strftime('%Y%m%d_%H%M%S')
if not os.path.exists(base_path):
os.makedirs(base_path)
video_obj = dict()
video_obj[1] = cv2.VideoCapture('http://localhost:6082/frame.mjpg')
video_obj[2] = cv2.VideoCapture('http://localhost:6083/frame.mjpg')
video_obj[3] = cv2.VideoCapture('http://localhost:6084/frame.mjpg')
video_obj[4] = cv2.VideoCapture('http://localhost:6085/frame.mjpg')
video_obj[5] = cv2.VideoCapture('http://localhost:6086/frame.mjpg')
for idx, obj in video_obj.items():
filepath = prestr + '_' + str(idx) +'.jpg'
print(filepath)
(success, image) = obj.read()
cv2.imwrite(filepath, image)
obj.release()
except Exception as E:
print(E)
time.sleep(15)