From a458b46f42702a2be27f67c4b158ec129931bb4c Mon Sep 17 00:00:00 2001 From: tian <11429339@qq.com> Date: Wed, 15 Apr 2026 10:12:00 +0800 Subject: [PATCH] Simplify workshoe runtime config surface --- configs/full_pipeline_1080p.json | 3 - configs/full_pipeline_1080p_test_alarm.json | 4 - ..._two_stage_workshoe_alarm_v8s_shoe640.json | 3 - ...age_workshoe_alarm_v8s_shoe640_strict.json | 3 - docs/config_guide.md | 91 ++++++++++++------- plugins/logic_gate/logic_gate_node.cpp | 13 +-- 6 files changed, 60 insertions(+), 57 deletions(-) diff --git a/configs/full_pipeline_1080p.json b/configs/full_pipeline_1080p.json index ae5633f..4acd662 100644 --- a/configs/full_pipeline_1080p.json +++ b/configs/full_pipeline_1080p.json @@ -190,9 +190,6 @@ "violation_class": 2, "min_person_score": 0.30, "min_shoe_score": 0.22, - "require_person_track_id": true, - "attach_person_track_to_shoe": true, - "emit_missing_violation": false, "foot_region": { "x_offset": -0.24, "y_offset": 0.64, diff --git a/configs/full_pipeline_1080p_test_alarm.json b/configs/full_pipeline_1080p_test_alarm.json index 6e74efd..2941fe6 100644 --- a/configs/full_pipeline_1080p_test_alarm.json +++ b/configs/full_pipeline_1080p_test_alarm.json @@ -217,15 +217,11 @@ "violation_class": 2, "min_person_score": 0.3, "min_shoe_score": 0.22, - "require_person_track_id": true, - "attach_person_track_to_shoe": true, - "emit_missing_violation": false, "foot_region": { "y_offset": 0.7, "width_scale": 1.6, "height_scale": 0.4 }, - "enable_size_preferred": true, "min_shoe_height_ratio": 0.08, "min_shoe_area_ratio": 0.012, "max_shoe_height_ratio": 0.14, diff --git a/configs/person_shoe_two_stage_workshoe_alarm_v8s_shoe640.json b/configs/person_shoe_two_stage_workshoe_alarm_v8s_shoe640.json index e8ea068..8a0ec92 100644 --- a/configs/person_shoe_two_stage_workshoe_alarm_v8s_shoe640.json +++ b/configs/person_shoe_two_stage_workshoe_alarm_v8s_shoe640.json @@ -130,9 +130,6 @@ "violation_class": 2, "min_person_score": 0.30, "min_shoe_score": 0.15, - "require_person_track_id": true, - "attach_person_track_to_shoe": true, - "emit_missing_violation": false, "foot_region": { "x_offset": -0.24, "y_offset": 0.64, diff --git a/configs/person_shoe_two_stage_workshoe_alarm_v8s_shoe640_strict.json b/configs/person_shoe_two_stage_workshoe_alarm_v8s_shoe640_strict.json index 2a27396..3855913 100644 --- a/configs/person_shoe_two_stage_workshoe_alarm_v8s_shoe640_strict.json +++ b/configs/person_shoe_two_stage_workshoe_alarm_v8s_shoe640_strict.json @@ -130,9 +130,6 @@ "violation_class": 2, "min_person_score": 0.30, "min_shoe_score": 0.22, - "require_person_track_id": true, - "attach_person_track_to_shoe": true, - "emit_missing_violation": false, "foot_region": { "x_offset": -0.24, "y_offset": 0.64, diff --git a/docs/config_guide.md b/docs/config_guide.md index 7a84dd0..ecce9eb 100644 --- a/docs/config_guide.md +++ b/docs/config_guide.md @@ -228,7 +228,7 @@ input_rtsp "model_path": "./models/shoe_detector_openimages_ppe_v1.rknn", "model_w": 640, "model_h": 640, - "conf": 0.15, + "conf": 0.22, "nms": 0.45, "v8_box_format": "cxcywh", "append_detections": true, @@ -239,10 +239,10 @@ input_rtsp "debug_roi_class_id": -1, "max_rois": 3, "min_person_height": 60, - "x_offset": -0.24, - "y_offset": 0.64, - "width_scale": 1.48, - "height_scale": 0.58 + "max_box_area_ratio": 0.6, + "y_offset": 0.7, + "width_scale": 1.6, + "height_scale": 0.4 } } ``` @@ -257,17 +257,21 @@ input_rtsp | 参数 | 作用 | 当前建议 | |------|------|----------| -| `conf` | 鞋候选召回阈值 | `0.15` | +| `conf` | 鞋候选召回阈值 | `0.22` | | `append_detections` | 保留人框并追加鞋框 | 必须 `true` | | `dynamic_roi.max_rois` | 每帧最多处理多少人 | `3` | | `dynamic_roi.min_person_height` | 过滤太远的人 | `60` | -| `x_offset/y_offset/width_scale/height_scale` | 脚部 ROI 形状 | 按高机位场景调优 | +| `dynamic_roi.max_box_area_ratio` | 过滤接近整块脚区的大误框 | `0.6` | +| `dynamic_roi.y_offset` | 脚部 ROI 起点高度 | `0.7` | +| `dynamic_roi.width_scale` | 脚部 ROI 宽度比例 | `1.6` | +| `dynamic_roi.height_scale` | 脚部 ROI 高度比例 | `0.4` | 说明: - `shoe_det.conf` 看起来偏低,这是有意为之 - 当前方案依赖“低阈值召回 + 人鞋关联 + 颜色判断 + 告警节流”整体收敛 - 在高机位小鞋场景中,如果把这里直接调到 `0.4` 或 `0.5`,通常会明显漏检 +- 横向 ROI 已固定为按 `width_scale` 自动居中,不再提供 `x_offset` 配置 ### 3.6 logic_gate @@ -285,16 +289,20 @@ input_rtsp "shoe_class": 1, "violation_class": 2, "min_person_score": 0.30, - "min_shoe_score": 0.15, - "require_person_track_id": true, - "attach_person_track_to_shoe": true, - "emit_missing_violation": false, + "min_shoe_score": 0.22, "foot_region": { - "x_offset": -0.24, - "y_offset": 0.64, - "width_scale": 1.48, - "height_scale": 0.58 - } + "y_offset": 0.7, + "width_scale": 1.6, + "height_scale": 0.4 + }, + "min_shoe_height_ratio": 0.08, + "min_shoe_area_ratio": 0.012, + "max_shoe_height_ratio": 0.14, + "max_shoe_width_ratio": 0.38, + "max_shoe_area_ratio": 0.05, + "max_shoe_roi_width_ratio": 0.45, + "max_shoe_roi_height_ratio": 0.35, + "max_shoe_roi_area_ratio": 0.10 } } ``` @@ -305,6 +313,24 @@ input_rtsp - 把人的 `track_id` 传给鞋 - 不再输出“没鞋违规” +关键参数: + +| 参数 | 作用 | 当前建议 | +|------|------|----------| +| `min_person_score` | 进入人鞋关联的人框最低分数 | `0.30` | +| `min_shoe_score` | 进入人鞋关联的鞋框最低分数 | `0.22` | +| `foot_region.y_offset` | 关联阶段脚部 ROI 起点高度 | `0.7` | +| `foot_region.width_scale` | 关联阶段脚部 ROI 宽度比例 | `1.6` | +| `foot_region.height_scale` | 关联阶段脚部 ROI 高度比例 | `0.4` | +| `min_shoe_height_ratio` | 过滤过矮鞋框 | `0.08` | +| `min_shoe_area_ratio` | 过滤过小鞋框 | `0.012` | +| `max_shoe_height_ratio` | 过滤过高鞋框 | `0.14` | +| `max_shoe_width_ratio` | 过滤过宽鞋框 | `0.38` | +| `max_shoe_area_ratio` | 过滤过大鞋框 | `0.05` | +| `max_shoe_roi_width_ratio` | 过滤相对脚部 ROI 过宽的鞋框 | `0.45` | +| `max_shoe_roi_height_ratio` | 过滤相对脚部 ROI 过高的鞋框 | `0.35` | +| `max_shoe_roi_area_ratio` | 过滤相对脚部 ROI 过大的鞋框 | `0.10` | + #### 模式二:ppe_boots_check ```json @@ -318,10 +344,7 @@ input_rtsp "boots_class": 1, "violation_class": 2, "color_check": { - "enable": true, - "method": "brightness", - "dark_threshold": 90, - "roi_expand": 1.0 + "enable": true } } ``` @@ -332,14 +355,6 @@ input_rtsp - 深色鞋:视为合规 - 非深色鞋:追加 `cls=2` 的违规框,供 OSD 和 alarm 使用 -颜色参数建议: - -| 参数 | 含义 | 当前建议 | -|------|------|----------| -| `method` | 颜色判断方式 | `brightness` | -| `dark_threshold` | 深色阈值 | `90` | -| `roi_expand` | 颜色分析区域扩展 | `1.0` | - ### 3.7 osd ```json @@ -473,8 +488,8 @@ input_rtsp 目标:先保证人体框稳定且脚下留出空间 2. `ai_shoe_det.conf` 和 `dynamic_roi` 目标:先让鞋框能出来 -3. `logic_gate.color_check.dark_threshold` - 目标:区分黑色劳保鞋和拖鞋/浅色鞋 +3. `shoe_assoc.person_shoe_check` 尺寸过滤参数 + 目标:拦住双鞋框、大框和整块裤腿误框 4. `alarm.min_hits / min_duration_ms / cooldown_ms` 目标:把“会报警”收敛成“稳一点再报警” @@ -491,8 +506,11 @@ input_rtsp | `shoe_det.dynamic_roi` | `max_rois` | 控制每帧最多处理多少人 | 覆盖更多人,但 FPS 下降 | 更省资源,但多人时会漏掉部分鞋 | | `shoe_det.dynamic_roi` | `min_person_height` | 过滤远景小人 | 远处小人不参与鞋检 | 更多远景人进入鞋检 | | `shoe_det.dynamic_roi` | `max_box_area_ratio` | 过滤接近整块脚区的大误框 | 大蓝框减少 | 更容易保留整块 ROI 级误报 | +| `shoe_det.dynamic_roi` | `y_offset / width_scale / height_scale` | 控制鞋检测脚部 ROI 的位置和范围 | ROI 更宽/更高/更靠下 | ROI 更窄/更低/更靠上 | | `shoe_assoc` | `min_shoe_score` | 控制低分鞋框是否参与人鞋关联 | 低分误框减少 | 弱鞋框更容易进入后续逻辑 | -| `shoe_color` | `dark_threshold` | 控制黑鞋/非黑鞋边界 | 更多深灰鞋被判合规 | 更多鞋会被判非黑鞋 | +| `shoe_assoc` | `max_shoe_width_ratio` | 控制偏宽大框是否被过滤 | 双鞋合并框、大鞋框更少 | 更容易放过双鞋框和裤腿大框 | +| `shoe_assoc` | `max_shoe_area_ratio` | 控制偏大面积鞋框是否被过滤 | 大误框更少 | 大误框更容易进入颜色判断 | +| `shoe_assoc` | `max_shoe_roi_width_ratio / max_shoe_roi_height_ratio / max_shoe_roi_area_ratio` | 控制相对脚部 ROI 的鞋框上限 | 更能拦住整块脚区误框 | 更容易保留整块 ROI 级误报 | | `alarm` | `min_duration_ms` | 控制要稳定多久才报警 | 更稳,但慢一点 | 更灵敏,但更容易闪报 | | `alarm` | `cooldown_ms` | 控制两次告警间隔 | 减少重复告警 | 同一事件会更频繁重复报 | @@ -504,17 +522,22 @@ input_rtsp - 先降低 `shoe_det.conf` - 再降低 `shoe_assoc.min_shoe_score` - 必要时降低 `dynamic_roi.min_person_height` + - 再检查 `dynamic_roi.y_offset / width_scale / height_scale` 是否把脚部 ROI 裁偏 - 蓝框误报多: - 先提高 `shoe_det.conf` - 再提高 `shoe_assoc.min_shoe_score` - 如出现整块脚区级误框,再降低 `max_box_area_ratio` + - 如出现双鞋合并框或裤腿大框,再降低 `max_shoe_width_ratio / max_shoe_area_ratio` - 黑色劳保鞋被误报: - - 提高 `shoe_color.dark_threshold` + - 先检查是否有大框、双鞋框、裤腿框混进来 + - 优先收紧 `max_shoe_width_ratio / max_shoe_area_ratio / max_shoe_roi_*` - 非黑鞋不报警: - - 降低 `shoe_color.dark_threshold` + - 先检查鞋框是否进入 `shoe selected` + - 再检查 `shoe_det.conf / shoe_assoc.min_shoe_score` + - 再检查 `dynamic_roi` 与 `foot_region` 是否把脚部 ROI 裁偏 - 检查 `alarm.min_score` - 检查 `alarm.min_duration_ms / min_hits` @@ -527,7 +550,7 @@ input_rtsp ## 7. 常见问题 -### Q1: 为什么鞋子检测阈值只有 0.15? +### Q1: 为什么鞋子检测阈值只有 0.22? 因为当前场景是高机位、小鞋目标,单纯靠高阈值会先漏掉大量鞋框。系统依赖多级过滤,而不是单级高阈值。 diff --git a/plugins/logic_gate/logic_gate_node.cpp b/plugins/logic_gate/logic_gate_node.cpp index 7013a3f..efe4324 100644 --- a/plugins/logic_gate/logic_gate_node.cpp +++ b/plugins/logic_gate/logic_gate_node.cpp @@ -22,11 +22,11 @@ struct PersonShoeCheckConfig { int violation_class = 2; float min_person_score = 0.0f; float min_shoe_score = 0.0f; - bool require_person_track_id = false; + bool require_person_track_id = true; bool use_person_bbox_for_violation = true; bool attach_person_track_to_shoe = true; - bool emit_missing_violation = true; - bool enable_size_preferred = false; + bool emit_missing_violation = false; + bool enable_size_preferred = true; float min_shoe_height_ratio = 0.08f; float min_shoe_area_ratio = 0.012f; float max_shoe_height_ratio = 0.24f; @@ -224,16 +224,9 @@ private: config.person_shoe.violation_class = ps->ValueOr("violation_class", config.person_shoe.violation_class); config.person_shoe.min_person_score = ps->ValueOr("min_person_score", config.person_shoe.min_person_score); config.person_shoe.min_shoe_score = ps->ValueOr("min_shoe_score", config.person_shoe.min_shoe_score); - config.person_shoe.require_person_track_id = ps->ValueOr("require_person_track_id", config.person_shoe.require_person_track_id); config.person_shoe.use_person_bbox_for_violation = ps->ValueOr( "use_person_bbox_for_violation", config.person_shoe.use_person_bbox_for_violation); - config.person_shoe.attach_person_track_to_shoe = ps->ValueOr( - "attach_person_track_to_shoe", config.person_shoe.attach_person_track_to_shoe); - config.person_shoe.emit_missing_violation = ps->ValueOr( - "emit_missing_violation", config.person_shoe.emit_missing_violation); config.person_shoe.match_iou = ps->ValueOr("match_iou", config.person_shoe.match_iou); - config.person_shoe.enable_size_preferred = ps->ValueOr( - "enable_size_preferred", config.person_shoe.enable_size_preferred); config.person_shoe.min_shoe_height_ratio = ps->ValueOr( "min_shoe_height_ratio", config.person_shoe.min_shoe_height_ratio); config.person_shoe.min_shoe_area_ratio = ps->ValueOr(