set option for per camera frame timeout

This commit is contained in:
alan 2019-12-26 11:34:19 -08:00
parent 534b2b3869
commit db66ecd449
2 changed files with 5 additions and 3 deletions

View File

@ -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

View File

@ -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