From 2d5ada2909468b53ad9398854b6b13255dcc3d97 Mon Sep 17 00:00:00 2001 From: 16337 <1633794139@qq.com> Date: Thu, 22 Jan 2026 15:53:31 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=BB=9F=E4=B8=80=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.py | 6 +++--- config.yaml | 10 +++++----- inference/rules/algorithms.py | 3 ++- tests/test_core.py | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/config.py b/config.py index 420e4c8..2e881cf 100644 --- a/config.py +++ b/config.py @@ -66,9 +66,9 @@ class WorkingHours(BaseModel): class AlgorithmsConfig(BaseModel): - leave_post_threshold_sec: int = 360 - leave_post_confirm_sec: int = 30 - leave_post_return_sec: int = 5 + leave_post_threshold_sec: int = 300 + leave_post_confirm_sec: int = 10 + leave_post_return_sec: int = 30 intrusion_check_interval_sec: float = 1.0 intrusion_direction_sensitive: bool = False diff --git a/config.yaml b/config.yaml index b2fcdd8..74586ea 100644 --- a/config.yaml +++ b/config.yaml @@ -70,9 +70,9 @@ working_hours: # 算法默认参数 algorithms: leave_post: - default_threshold_sec: 360 # 离岗超时(6分钟) - confirm_sec: 30 # 离岗确认时间 - return_sec: 5 # 上岗确认时间 + threshold_sec: 300 # 离岗超时(5分钟) + confirm_sec: 10 # 上岗确认时间(10秒) + return_sec: 30 # 离岗缓冲时间(30秒) intrusion: check_interval_sec: 1.0 # 检测间隔 direction_sensitive: false # 方向敏感 @@ -94,7 +94,7 @@ monitoring: # 大模型配置(预留) llm: enabled: false - api_key: "" - base_url: "" + api_key: "sk-21e61bef09074682b589da3bdbfe07a2" + base_url: "https://dashscope.aliyuncs.com/compatible-mode/v1" model: "qwen3-vl-max" timeout: 30 diff --git a/inference/rules/algorithms.py b/inference/rules/algorithms.py index f3c355f..c59c70e 100644 --- a/inference/rules/algorithms.py +++ b/inference/rules/algorithms.py @@ -205,6 +205,7 @@ class IntrusionAlgorithm: def process( self, + roi_id: str, camera_id: str, tracks: List[Dict], current_time: Optional[datetime] = None, @@ -236,7 +237,7 @@ class IntrusionAlgorithm: for track_data in tracked: x1, y1, x2, y2, track_id = track_data - cooldown_key = f"{camera_id}_{int(track_id)}" + cooldown_key = f"{roi_id}_{int(track_id)}" if cooldown_key not in self.alert_cooldowns or ( now - self.alert_cooldowns[cooldown_key] diff --git a/tests/test_core.py b/tests/test_core.py index c673f2b..f09f57d 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -58,7 +58,7 @@ def test_leave_post_algorithm_process(): {"bbox": [100, 100, 200, 200], "conf": 0.9, "cls": 0}, ] - alerts = algo.process("test_cam", tracks, datetime.now()) + alerts = algo.process("roi_1", "test_cam", tracks, datetime.now()) assert isinstance(alerts, list)