mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-08-04 13:47:37 +02:00
make stationary_threshold configurable
This commit is contained in:
parent
5cff849e59
commit
3e90f3032c
@ -159,9 +159,11 @@ detect:
|
|||||||
enabled: True
|
enabled: True
|
||||||
# Optional: Number of frames without a detection before frigate considers an object to be gone. (default: 5x the frame rate)
|
# Optional: Number of frames without a detection before frigate considers an object to be gone. (default: 5x the frame rate)
|
||||||
max_disappeared: 25
|
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.
|
# 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
|
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
|
# Optional: Object configuration
|
||||||
# NOTE: Can be overridden at the camera level
|
# NOTE: Can be overridden at the camera level
|
||||||
|
@ -177,6 +177,11 @@ class DetectConfig(FrigateBaseModel):
|
|||||||
title="Frame interval for checking stationary objects.",
|
title="Frame interval for checking stationary objects.",
|
||||||
ge=0,
|
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):
|
class FilterConfig(FrigateBaseModel):
|
||||||
|
@ -48,7 +48,7 @@ class ObjectTracker:
|
|||||||
del self.tracked_objects[id]
|
del self.tracked_objects[id]
|
||||||
del self.disappeared[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
|
# returns False if the object has moved outside its previous position
|
||||||
def update_position(self, id, box):
|
def update_position(self, id, box):
|
||||||
position = self.positions[id]
|
position = self.positions[id]
|
||||||
@ -78,9 +78,9 @@ class ObjectTracker:
|
|||||||
}
|
}
|
||||||
return False
|
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
|
# and recompute the position box
|
||||||
if len(position["xmins"]) < 10:
|
if len(position["xmins"]) < self.detect_config.stationary_threshold:
|
||||||
position["xmins"].append(xmin)
|
position["xmins"].append(xmin)
|
||||||
position["ymins"].append(ymin)
|
position["ymins"].append(ymin)
|
||||||
position["xmaxs"].append(xmax)
|
position["xmaxs"].append(xmax)
|
||||||
|
@ -507,8 +507,8 @@ def process_frames(
|
|||||||
stationary_object_ids = [
|
stationary_object_ids = [
|
||||||
obj["id"]
|
obj["id"]
|
||||||
for obj in object_tracker.tracked_objects.values()
|
for obj in object_tracker.tracked_objects.values()
|
||||||
# if there hasn't been motion for 10 frames
|
# if there hasn't been motion for N frames
|
||||||
if obj["motionless_count"] >= 10
|
if obj["motionless_count"] >= detect_config.stationary_threshold
|
||||||
# and it isn't due for a periodic check
|
# and it isn't due for a periodic check
|
||||||
and (
|
and (
|
||||||
detect_config.stationary_interval == 0
|
detect_config.stationary_interval == 0
|
||||||
|
Loading…
Reference in New Issue
Block a user