From 1211fc72076c8818f3f654465b02cf26f28846d1 Mon Sep 17 00:00:00 2001 From: 16337 <1633794139@qq.com> Date: Sun, 8 Mar 2026 23:20:31 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=A6=BB=E5=B2=97=E7=AE=97=E6=B3=95?= =?UTF-8?q?=E6=BB=91=E5=8A=A8=E7=AA=97=E5=8F=A3=E6=8A=97=E6=8A=96=E5=8A=A8?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 上岗确认阈值从 0.7 降为 0.6,降低漏确认 - 离岗触发从 ratio==0 改为 ratio<0.2,允许 20% 抖动 - 离岗中断从单帧判断改为 ratio>=0.5,避免偶尔一帧误检打断确认 - 入侵算法不变,通过调高 conf 到 0.6 解决误报 Co-Authored-By: Claude Opus 4.6 --- algorithms.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/algorithms.py b/algorithms.py index ce0e904..fc25168 100644 --- a/algorithms.py +++ b/algorithms.py @@ -241,7 +241,7 @@ class LeavePostAlgorithm: self.state_start_time = current_time self.detection_window.clear() logger.debug(f"ROI {roi_id}: CONFIRMING_ON_DUTY → INIT (人消失)") - elif elapsed >= self.confirm_on_duty_sec and detection_ratio >= 0.7: + elif elapsed >= self.confirm_on_duty_sec and detection_ratio >= 0.6: # 上岗确认成功(命中率>=70%) self.state = self.STATE_ON_DUTY self.state_start_time = current_time @@ -250,8 +250,8 @@ class LeavePostAlgorithm: elif self.state == self.STATE_ON_DUTY: # 在岗状态:监控是否离岗 - if detection_ratio == 0: - # 滑动窗口内完全没有人,进入离岗确认 + if detection_ratio < 0.2: + # 滑动窗口内 80% 以上帧无人,进入离岗确认 self.state = self.STATE_CONFIRMING_OFF_DUTY self.state_start_time = current_time logger.debug(f"ROI {roi_id}: ON_DUTY → CONFIRMING_OFF_DUTY") @@ -260,12 +260,12 @@ class LeavePostAlgorithm: # 离岗确认中:需要持续未检测到人 elapsed = (current_time - self.state_start_time).total_seconds() - if roi_has_person: - # 人回来了,回到ON_DUTY + if detection_ratio >= 0.5: + # 窗口内检测率恢复到 50% 以上,人确实回来了 self.state = self.STATE_ON_DUTY self.state_start_time = current_time - logger.debug(f"ROI {roi_id}: CONFIRMING_OFF_DUTY → ON_DUTY (人回来了)") - elif elapsed >= self.confirm_off_duty_sec and detection_ratio == 0: + logger.debug(f"ROI {roi_id}: CONFIRMING_OFF_DUTY → ON_DUTY (人回来了, ratio={detection_ratio:.2f})") + elif elapsed >= self.confirm_off_duty_sec and detection_ratio < 0.2: # 离岗确认成功,进入倒计时 self.state = self.STATE_OFF_DUTY_COUNTDOWN self.state_start_time = current_time