From a3fa97dd52e168b60c6b833821c0d75ee00984ad Mon Sep 17 00:00:00 2001 From: Blake Blackshear Date: Sun, 23 Feb 2020 07:55:51 -0600 Subject: [PATCH] ensure missing objects are expired even when other object types are in the frame --- frigate/objects.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/frigate/objects.py b/frigate/objects.py index 2c241667c..49cf5377f 100644 --- a/frigate/objects.py +++ b/frigate/objects.py @@ -49,14 +49,6 @@ class ObjectTracker(): obj['history'] = [entry] def match_and_update(self, frame_time, new_objects): - if len(new_objects) == 0: - for id in list(self.tracked_objects.keys()): - if self.disappeared[id] >= self.max_disappeared: - self.deregister(id) - else: - self.disappeared[id] += 1 - return - # group by name new_object_groups = defaultdict(lambda: []) for obj in new_objects: @@ -69,6 +61,18 @@ class ObjectTracker(): 'frame_time': frame_time }) + # update any tracked objects with labels that are not + # seen in the current objects and deregister if needed + for id, obj in self.tracked_objects.items(): + if not obj['label'] in new_object_groups: + if self.disappeared[id] >= self.max_disappeared: + self.deregister(id) + else: + self.disappeared[id] += 1 + + if len(new_objects) == 0: + return + # track objects for each label type for label, group in new_object_groups.items(): current_objects = [o for o in self.tracked_objects.values() if o['label'] == label]