forked from Github/frigate
config option for stationary detection interval
This commit is contained in:
@@ -162,6 +162,9 @@ class DetectConfig(FrigateBaseModel):
|
||||
max_disappeared: Optional[int] = Field(
|
||||
title="Maximum number of frames the object can dissapear before detection ends."
|
||||
)
|
||||
stationary_interval: Optional[int] = Field(
|
||||
title="Frame interval for checking stationary objects."
|
||||
)
|
||||
|
||||
|
||||
class FilterConfig(FrigateBaseModel):
|
||||
@@ -745,6 +748,11 @@ class FrigateConfig(FrigateBaseModel):
|
||||
if camera_config.detect.max_disappeared is None:
|
||||
camera_config.detect.max_disappeared = max_disappeared
|
||||
|
||||
# Default stationary_interval configuration
|
||||
stationary_interval = camera_config.detect.fps * 10
|
||||
if camera_config.detect.stationary_interval is None:
|
||||
camera_config.detect.stationary_interval = stationary_interval
|
||||
|
||||
# FFMPEG input substitution
|
||||
for input in camera_config.ffmpeg.inputs:
|
||||
input.path = input.path.format(**FRIGATE_ENV_VARS)
|
||||
|
||||
@@ -14,7 +14,7 @@ import numpy as np
|
||||
from cv2 import cv2
|
||||
from setproctitle import setproctitle
|
||||
|
||||
from frigate.config import CameraConfig
|
||||
from frigate.config import CameraConfig, DetectConfig
|
||||
from frigate.edgetpu import RemoteObjectDetector
|
||||
from frigate.log import LogPipe
|
||||
from frigate.motion import MotionDetector
|
||||
@@ -367,6 +367,7 @@ def track_camera(
|
||||
frame_queue,
|
||||
frame_shape,
|
||||
model_shape,
|
||||
config.detect,
|
||||
frame_manager,
|
||||
motion_detector,
|
||||
object_detector,
|
||||
@@ -448,6 +449,7 @@ def process_frames(
|
||||
frame_queue: mp.Queue,
|
||||
frame_shape,
|
||||
model_shape,
|
||||
detect_config: DetectConfig,
|
||||
frame_manager: FrameManager,
|
||||
motion_detector: MotionDetector,
|
||||
object_detector: RemoteObjectDetector,
|
||||
@@ -502,12 +504,13 @@ def process_frames(
|
||||
motion_boxes = motion_detector.detect(frame)
|
||||
|
||||
# get stationary object ids
|
||||
# check every 10th frame for stationary objects
|
||||
# check every Nth frame for stationary objects
|
||||
# disappeared objects are not stationary
|
||||
stationary_object_ids = [
|
||||
obj["id"]
|
||||
for obj in object_tracker.tracked_objects.values()
|
||||
if obj["motionless_count"] >= 10
|
||||
and obj["motionless_count"] % 10 != 0
|
||||
and obj["motionless_count"] % detect_config.stationary_interval != 0
|
||||
and object_tracker.disappeared[obj["id"]] == 0
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user