diff --git a/frigate/util.py b/frigate/util.py index e6491628c..f42ee82c0 100755 --- a/frigate/util.py +++ b/frigate/util.py @@ -126,12 +126,16 @@ class EventsPerSecond: self._start = datetime.datetime.now().timestamp() def update(self): + if self._start is None: + self.start() self._timestamps.append(datetime.datetime.now().timestamp()) # truncate the list when it goes 100 over the max_size if len(self._timestamps) > self._max_events+100: self._timestamps = self._timestamps[(1-self._max_events):] def eps(self, last_n_seconds=10): + if self._start is None: + self.start() # compute the (approximate) events in the last n seconds now = datetime.datetime.now().timestamp() seconds = min(now-self._start, last_n_seconds) diff --git a/frigate/video.py b/frigate/video.py index b9d735d78..bf2664f3e 100755 --- a/frigate/video.py +++ b/frigate/video.py @@ -219,7 +219,7 @@ def track_camera(name, config, frame_queue, frame_shape, detection_queue, detect plasma_client = PlasmaFrameManager() process_frames(name, frame_queue, frame_shape, plasma_client, motion_detector, object_detector, - object_tracker, detected_objects_queue, fps, detection_frame, objects_to_track, object_filters, mask, stop_event) + object_tracker, detected_objects_queue, fps, detection_fps, detection_frame, objects_to_track, object_filters, mask, stop_event) print(f"{name}: exiting subprocess") @@ -255,7 +255,7 @@ def detect(object_detector, frame, region, objects_to_track, object_filters, mas def process_frames(camera_name: str, frame_queue: mp.Queue, frame_shape, frame_manager: FrameManager, motion_detector: MotionDetector, object_detector: RemoteObjectDetector, object_tracker: ObjectTracker, - detected_objects_queue: mp.Queue, fps: mp.Value, current_frame_time: mp.Value, + detected_objects_queue: mp.Queue, fps: mp.Value, detection_fps: mp.Value, current_frame_time: mp.Value, objects_to_track: List[str], object_filters: Dict, mask, stop_event: mp.Event, exit_on_empty: bool = False): @@ -352,3 +352,5 @@ def process_frames(camera_name: str, frame_queue: mp.Queue, frame_shape, # add to the queue detected_objects_queue.put((camera_name, frame_time, object_tracker.tracked_objects)) + + detection_fps.value = object_detector.fps.eps()