Skip to content

Commit

Permalink
deregister based on max_frames setting
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeblackshear committed Feb 19, 2022
1 parent ff19cdb commit 395c163
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion frigate/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,33 @@ def update_position(self, id, box):

return True

def is_expired(self, id):
obj = self.tracked_objects[id]
# get the max frames for this label type or the default
max_frames = self.detect_config.stationary.max_frames.objects.get(
obj["label"], self.detect_config.stationary.max_frames.default
)

# if there is no max_frames for this label type, continue
if max_frames is None:
return False

# if the object has exceeded the max_frames setting, deregister
if (
obj["motionless_count"] - self.detect_config.stationary.threshold
> max_frames
):
print(f"expired: {obj['motionless_count']}")
return True

def update(self, id, new_obj):
self.disappeared[id] = 0
# update the motionless count if the object has not moved to a new position
if self.update_position(id, new_obj["box"]):
self.tracked_objects[id]["motionless_count"] += 1
if self.is_expired(id):
self.deregister(id)
return
else:
# register the first position change and then only increment if
# the object was previously stationary
Expand All @@ -112,9 +134,11 @@ def update(self, id, new_obj):
self.tracked_objects[id].update(new_obj)

def update_frame_times(self, frame_time):
for id in self.tracked_objects.keys():
for id in list(self.tracked_objects.keys()):
self.tracked_objects[id]["frame_time"] = frame_time
self.tracked_objects[id]["motionless_count"] += 1
if self.is_expired(id):
self.deregister(id)

def match_and_update(self, frame_time, new_objects):
# group by name
Expand Down

0 comments on commit 395c163

Please sign in to comment.