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 10, 2022
1 parent 4deb365 commit adbc54b
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

This comment has been minimized.

Copy link
@elgorro

elgorro Feb 10, 2022

@blakeblackshear missing a break here?

This comment has been minimized.

Copy link
@blakeblackshear

blakeblackshear Feb 10, 2022

Author Owner

Not sure what you mean.

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 adbc54b

Please sign in to comment.