Add object detection, tracking, mobile notifications, and search to any security camera.
2 sec segments and dont save image for now
Rory Clear7ff86cb95fd4
diff --git a/experimental/clearcam_rtsp.py b/experimental/clearcam_rtsp.pyindex 7f8befd..0f9090c 100644--- a/experimental/clearcam_rtsp.py+++ b/experimental/clearcam_rtsp.py@@ -449,11 +449,6 @@ class VideoCapture:if time.time() - last_det >= 60: # once per min for nowsend_det = Trueprint("DETECTED") # todo, magic 5, change of 5 over 10 frames = detection- os.makedirs("event_images", exist_ok=True)- timestamp = datetime.now().strftime("%Y-%m-%d_%H:%M:%S")- filename = f"event_images/frame_{timestamp}.jpg"- cv2.imwrite(filename, self.annotated_frame)- if userID is not None: send_notif(userID)last_det = time.time()if (send_det and userID is not None) and time.time() - last_det >= 15: #send 15ish second clip afteros.makedirs("event_clips", exist_ok=True)@@ -517,7 +512,7 @@ class VideoCapture:self.proc.kill()class HLSStreamer:- def __init__(self, video_capture, output_dir="hls_output", segment_time=5):+ def __init__(self, video_capture, output_dir="hls_output", segment_time=2):self.cam = video_captureself.output_dir = Path(output_dir)self.segment_time = segment_time@@ -536,7 +531,7 @@ class HLSStreamer:def start(self):self.running = Trueself.current_stream_dir = self._get_new_stream_dir()- self.recent_segments = deque(maxlen=3)+ self.recent_segments = deque(maxlen=8)# Start FFmpeg process for HLS streaming to local filesffmpeg_cmd = ["ffmpeg",@@ -593,7 +588,7 @@ class HLSStreamer:while self.running:segment_files = sorted(self.current_stream_dir.glob("*.ts"), key=os.path.getmtime)self.recent_segments.clear()- self.recent_segments.extend(segment_files[-3:]) # last 3 for now+ self.recent_segments.extend(segment_files[-8:]) # last 3 for nowtime.sleep(self.segment_time / 2)def _feed_frames(self):