fix:修复 ROI 多边形未传递及空 ROI 判断逻辑错误导致的离岗告警失效问题。
根本原因: 1. pipeline.py 中调用 register_algorithm 时未传入 roi_polygon,导致算法内 roi_polygon 为空 2. is_point_in_roi 函数在 roi_polygon 为空或点数 <3 时错误返回 True,使系统误判“有人在岗” 3. 因此即使 ROI 内无人,算法也永远不会进入离岗倒计时 修复措施: - 在注册算法时正确传递 ROI 多边形坐标 - 修正 is_point_in_roi:当 ROI 无效时应返回 False(无人) - 确保无检测框时仍能触发状态机超时逻辑
This commit is contained in:
@@ -187,9 +187,9 @@ class InferencePipeline:
|
||||
roi_id,
|
||||
rule_type,
|
||||
{
|
||||
"threshold_sec": roi_config.get("threshold_sec", 360),
|
||||
"confirm_sec": roi_config.get("confirm_sec", 30),
|
||||
"return_sec": roi_config.get("return_sec", 5),
|
||||
"threshold_sec": roi_config.get("threshold_sec", 300),
|
||||
"confirm_sec": roi_config.get("confirm_sec", 10),
|
||||
"return_sec": roi_config.get("return_sec", 30),
|
||||
},
|
||||
)
|
||||
|
||||
@@ -217,22 +217,30 @@ class InferencePipeline:
|
||||
else:
|
||||
filtered_detections = detections
|
||||
|
||||
roi_detections: Dict[str, List[Dict]] = {}
|
||||
for detection in filtered_detections:
|
||||
matched_rois = detection.get("matched_rois", [])
|
||||
for roi_conf in matched_rois:
|
||||
roi_id = roi_conf["roi_id"]
|
||||
rule_type = roi_conf["rule"]
|
||||
if roi_id not in roi_detections:
|
||||
roi_detections[roi_id] = []
|
||||
roi_detections[roi_id].append(detection)
|
||||
|
||||
alerts = self.algo_manager.process(
|
||||
roi_id,
|
||||
str(camera_id),
|
||||
rule_type,
|
||||
[detection],
|
||||
datetime.now(),
|
||||
)
|
||||
for roi_config in roi_configs:
|
||||
roi_id = roi_config["roi_id"]
|
||||
rule_type = roi_config["rule"]
|
||||
roi_dets = roi_detections.get(roi_id, [])
|
||||
|
||||
for alert in alerts:
|
||||
self._handle_alert(camera_id, alert, frame, roi_conf)
|
||||
alerts = self.algo_manager.process(
|
||||
roi_id,
|
||||
str(camera_id),
|
||||
rule_type,
|
||||
roi_dets,
|
||||
datetime.now(),
|
||||
)
|
||||
|
||||
for alert in alerts:
|
||||
self._handle_alert(camera_id, alert, frame, roi_config)
|
||||
|
||||
def _handle_alert(
|
||||
self,
|
||||
|
||||
Reference in New Issue
Block a user