Skip to content

Commit

Permalink
selectively increment position changes
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeblackshear committed Feb 19, 2022
1 parent 8de15af commit 5a2e395
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/docs/integrations/mqtt.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Message published for each changed event. The first message is published when th
"has_snapshot": false,
"has_clip": false,
"motionless_count": 0, // number of frames the object has been motionless
"position_changes": 2 // number of times the object has changed position
"position_changes": 2 // number of times the object has moved from a stationary position
},
"after": {
"id": "1607123955.475377-mxklsc",
Expand Down
10 changes: 9 additions & 1 deletion frigate/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,16 @@ def update(self, id, new_obj):
if self.update_position(id, new_obj["box"]):
self.tracked_objects[id]["motionless_count"] += 1
else:
# register the first position change and then only increment if
# the object was previously stationary
if (
self.tracked_objects[id]["position_changes"] == 0
or self.tracked_objects[id]["motionless_count"]
>= self.detect_config.stationary_threshold
):
self.tracked_objects[id]["position_changes"] += 1
self.tracked_objects[id]["motionless_count"] = 0
self.tracked_objects[id]["position_changes"] += 1

self.tracked_objects[id].update(new_obj)

def update_frame_times(self, frame_time):
Expand Down

0 comments on commit 5a2e395

Please sign in to comment.