Skip to content

Commit

Permalink
ensure missing objects are expired even when other object types are i…
Browse files Browse the repository at this point in the history
…n the frame
  • Loading branch information
blakeblackshear committed Mar 4, 2020
1 parent 1d2a411 commit a3fa97d
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions frigate/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,6 @@ def add_history(self, obj):
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:
Expand All @@ -69,6 +61,18 @@ def match_and_update(self, frame_time, new_objects):
'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]
Expand Down

0 comments on commit a3fa97d

Please sign in to comment.