mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
ensure missing objects are expired even when other object types are in the frame
This commit is contained in:
parent
1d2a41129c
commit
a3fa97dd52
@ -49,14 +49,6 @@ class ObjectTracker():
|
|||||||
obj['history'] = [entry]
|
obj['history'] = [entry]
|
||||||
|
|
||||||
def match_and_update(self, frame_time, new_objects):
|
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
|
# group by name
|
||||||
new_object_groups = defaultdict(lambda: [])
|
new_object_groups = defaultdict(lambda: [])
|
||||||
for obj in new_objects:
|
for obj in new_objects:
|
||||||
@ -69,6 +61,18 @@ class ObjectTracker():
|
|||||||
'frame_time': frame_time
|
'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
|
# track objects for each label type
|
||||||
for label, group in new_object_groups.items():
|
for label, group in new_object_groups.items():
|
||||||
current_objects = [o for o in self.tracked_objects.values() if o['label'] == label]
|
current_objects = [o for o in self.tracked_objects.values() if o['label'] == label]
|
||||||
|
Loading…
Reference in New Issue
Block a user