From db66ecd4495ceafa2ca3177e07c260bccff98d2f Mon Sep 17 00:00:00 2001 From: alan Date: Thu, 26 Dec 2019 11:34:19 -0800 Subject: [PATCH] set option for per camera frame timeout --- frigate/objects.py | 5 +++-- frigate/video.py | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/frigate/objects.py b/frigate/objects.py index 0a7043a26..85b08997e 100644 --- a/frigate/objects.py +++ b/frigate/objects.py @@ -38,12 +38,13 @@ class ObjectCleaner(threading.Thread): # Maintains the frame and person with the highest score from the most recent # motion event class BestPersonFrame(threading.Thread): - def __init__(self, objects_parsed, recent_frames, detected_objects, label): + def __init__(self, objects_parsed, recent_frames, detected_objects, label, invalidate_seconds): threading.Thread.__init__(self) self.objects_parsed = objects_parsed self.recent_frames = recent_frames self.detected_objects = detected_objects self.label = label + self.invalidate_seconds = invalidate_seconds self.best_person = None self.best_frame = None @@ -73,7 +74,7 @@ class BestPersonFrame(threading.Thread): now = datetime.datetime.now().timestamp() # if the new best person is a higher score than the current best person # or the current person is more than 1 minute old, use the new best person - if new_best_person['score'] > self.best_person['score'] or (now - self.best_person['frame_time']) > 60: + if new_best_person['score'] > self.best_person['score'] or (now - self.best_person['frame_time']) > self.invalidate_seconds: self.best_person = new_best_person # make a copy of the recent frames diff --git a/frigate/video.py b/frigate/video.py index 04ec22c23..b26e3b003 100644 --- a/frigate/video.py +++ b/frigate/video.py @@ -132,6 +132,7 @@ class Camera: self.mqtt_topic_prefix = '{}/{}'.format(mqtt_prefix, self.name) self.label = config.get('label', 'person') self.dedupe_snapshot_publish = config.get('dedupe_snapshot_publish', False) + self.best_person_invalidate_seconds = config.get('best_person_invalidate_seconds', 60) # create a numpy array for the current frame in initialize to zeros self.current_frame = np.zeros(self.frame_shape, np.uint8) @@ -172,7 +173,7 @@ class Camera: self.frame_tracker.start() # start a thread to store the highest scoring recent person frame - self.best_person_frame = BestPersonFrame(self.objects_parsed, self.recent_frames, self.detected_objects, self.label) + self.best_person_frame = BestPersonFrame(self.objects_parsed, self.recent_frames, self.detected_objects, self.label, self.best_person_invalidate_seconds) self.best_person_frame.start() # start a thread to expire objects from the detected objects list