Skip to content

Add object detection, tracking, mobile notifications, and search to any security camera.

save img on detection

Rory Clearf4e87ed95e89
diff --git a/experimental/clearcam_rtsp.py b/experimental/clearcam_rtsp.py
index 982450a..ed1d94d 100644
--- a/experimental/clearcam_rtsp.py
+++ b/experimental/clearcam_rtsp.py
@@ -436,7 +436,12 @@ class VideoCapture:
for x in self.object_queue[0]: self.object_dict[int(x)] -= 1
del self.object_queue[0]
for k in self.object_dict.keys():
- if abs(self.object_dict[k] - last_dict[k]) > 5: print("DETECTED") # todo, magic 5, change of 5 over 10 frames = detection
+ if abs(self.object_dict[k] - last_dict[k]) > 5:
+ print("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_%f")
+ filename = f"event_images/frame_{timestamp}.jpg" # todo, once per min max, like ios
+ cv2.imwrite(filename, self.annotated_frame)
with self.lock:
self.raw_frame = frame.copy()
self.annotated_frame = self.draw_predictions(frame.copy(), filtered_preds)