mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
make stationary_threshold configurable
This commit is contained in:
parent
5cff849e59
commit
3e90f3032c
@ -159,9 +159,11 @@ detect:
|
||||
enabled: True
|
||||
# Optional: Number of frames without a detection before frigate considers an object to be gone. (default: 5x the frame rate)
|
||||
max_disappeared: 25
|
||||
# Optional: Frequency for running detection on stationary objects (default: 0)
|
||||
# Optional: Frequency for running detection on stationary objects (default: shown below)
|
||||
# When set to 0, object detection will never be run on stationary objects. If set to 10, it will be run on every 10th frame.
|
||||
stationary_interval: 0
|
||||
# Optional: Number of frames without a position change for an object to be considered stationary (default: shown below)
|
||||
stationary_threshold: 10
|
||||
|
||||
# Optional: Object configuration
|
||||
# NOTE: Can be overridden at the camera level
|
||||
|
@ -177,6 +177,11 @@ class DetectConfig(FrigateBaseModel):
|
||||
title="Frame interval for checking stationary objects.",
|
||||
ge=0,
|
||||
)
|
||||
stationary_threshold: Optional[int] = Field(
|
||||
default=10,
|
||||
title="Number of frames without a position change for an object to be considered stationary",
|
||||
ge=1,
|
||||
)
|
||||
|
||||
|
||||
class FilterConfig(FrigateBaseModel):
|
||||
|
@ -48,7 +48,7 @@ class ObjectTracker:
|
||||
del self.tracked_objects[id]
|
||||
del self.disappeared[id]
|
||||
|
||||
# tracks the current position of the object based on the last 10 bounding boxes
|
||||
# tracks the current position of the object based on the last N bounding boxes
|
||||
# returns False if the object has moved outside its previous position
|
||||
def update_position(self, id, box):
|
||||
position = self.positions[id]
|
||||
@ -78,9 +78,9 @@ class ObjectTracker:
|
||||
}
|
||||
return False
|
||||
|
||||
# if there are less than 10 entries for the position, add the bounding box
|
||||
# if there are less than stationary_threshold entries for the position, add the bounding box
|
||||
# and recompute the position box
|
||||
if len(position["xmins"]) < 10:
|
||||
if len(position["xmins"]) < self.detect_config.stationary_threshold:
|
||||
position["xmins"].append(xmin)
|
||||
position["ymins"].append(ymin)
|
||||
position["xmaxs"].append(xmax)
|
||||
|
@ -507,8 +507,8 @@ def process_frames(
|
||||
stationary_object_ids = [
|
||||
obj["id"]
|
||||
for obj in object_tracker.tracked_objects.values()
|
||||
# if there hasn't been motion for 10 frames
|
||||
if obj["motionless_count"] >= 10
|
||||
# if there hasn't been motion for N frames
|
||||
if obj["motionless_count"] >= detect_config.stationary_threshold
|
||||
# and it isn't due for a periodic check
|
||||
and (
|
||||
detect_config.stationary_interval == 0
|
||||
|
Loading…
Reference in New Issue
Block a user