Reduce exposed workshoe tuning parameters

This commit is contained in:
tian 2026-04-15 09:53:41 +08:00
parent df08b5bf64
commit 129bec9260
5 changed files with 265 additions and 133 deletions

View File

@ -229,17 +229,13 @@
"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,
"min_front_shoe_width_ratio": 0.18,
"max_front_shoe_aspect_ratio": 2.0,
"max_side_height_width_ratio": 1.2,
"max_shoe_aspect_ratio": 2.0
}
},
"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
}
},
{
"id": "shoe_color",
"type": "logic_gate",
@ -248,20 +244,15 @@
"cpu_affinity": [
6
],
"mode": "ppe_boots_check",
"anchor_class": 0,
"boots_class": 1,
"violation_class": 2,
"debug": true,
"color_check": {
"enable": true,
"method": "brightness",
"dark_threshold": 90,
"roi_expand": 1.0,
"center_w_scale": 0.6,
"center_h_scale": 0.6
}
},
"mode": "ppe_boots_check",
"anchor_class": 0,
"boots_class": 1,
"violation_class": 2,
"debug": true,
"color_check": {
"enable": true
}
},
{
"id": "pre_osd",
"type": "preprocess",

View File

@ -1,4 +1,4 @@
# 车间视频测试记录2026-04-13
# 车间视频测试记录2026-04-13,更新至 2026-04-15
## 1. 测试目的
@ -46,21 +46,45 @@
- 这些参数只适合联调阶段
- 不适合直接作为正式上线值
### 3.2 当前鞋颜色判定参数
### 3.2 当前鞋颜色判定配置与实现
当前测试版 `shoe_color.color_check` 参数为:
当前测试版 `shoe_color.color_check` 运行时仅保留:
- `enable = true`
但当前实际实现已经不是“整块鞋框平均亮度”或“中心 `60% x 60%` 平均亮度”,而是:
1. 先从鞋框内部取“中下部采样区”
- 横向取中间 `60%`
- 纵向取 `35% ~ 75%`
2. 再基于采样区做三段亮度占比统计
- 深色段:`0 ~ 80`
- 中间段:`81 ~ 160`
- 浅色段:`161 ~ 255`
3. 判定规则:
- `dark_ratio >= 0.45` 且深色占主导,判黑鞋
- `light_ratio >= 0.45` 且浅色占主导,判白鞋/浅色鞋
- 其余边界样本回退到 `brightness < dark_threshold && dark_ratio > 0.6`
当前这些值已作为程序内稳定默认值,不再建议作为运维配置暴露:
- `method = brightness`
- `dark_threshold = 90`
- `roi_expand = 1.0`
- `center_w_scale = 0.6`
- `center_h_scale = 0.6`
- 采样区:横向中间 `60%`、纵向 `35% ~ 75%`
说明:
- `shoe_color` 现在只负责颜色分析
- `shoe_color` 当前只负责颜色分析
- 几何阈值不再放在 `shoe_color` 内判断
- 鞋框几何筛选统一前置到 `shoe_assoc.person_shoe_check`
- 当前日志已输出:
- `Brightness`
- `dark_ratio`
- `mid_ratio`
- `light_ratio`
- `region`
- `sample`
### 3.3 当前鞋框几何筛选参数
@ -68,34 +92,68 @@
- `min_shoe_height_ratio = 0.08`
- `min_shoe_area_ratio = 0.012`
- `max_shoe_height_ratio = 0.24`
- `max_shoe_width_ratio = 0.60`
- `max_shoe_area_ratio = 0.15`
- `max_shoe_roi_width_ratio = 0.65`
- `max_shoe_roi_height_ratio = 0.60`
- `max_shoe_roi_area_ratio = 0.25`
- `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`
以下鞋型语义参数已回收到程序内稳定默认值,不再作为运行配置暴露:
- `min_front_shoe_width_ratio = 0.18`
- `max_front_shoe_aspect_ratio = 2.0`
- `max_side_height_width_ratio = 1.2`
- `max_shoe_aspect_ratio = 2.0`
### 3.4 当前脚部 ROI 参数
当前 `foot_region` / `dynamic_roi` 使用:
- `y_offset = 0.7`
- `width_scale = 1.6`
- `height_scale = 0.4`
说明:
- 横向不再手工调 `x_offset`
- 脚部 ROI 现在按 `width_scale` 自动居中
- 当前脚部 ROI 构造逻辑为:
- 以人体框为基准
- 横向按宽度比例居中展开
- 纵向从人体下半部开始覆盖脚部与少量脚下环境
## 4. 当前设备侧代码调试状态
本轮在 `3588` 上做过的关键修正:
1. 颜色分析不再直接看整块鞋框,而是看鞋框中心 `60% x 60%`
2. `shoe_color` 不再处理未成功关联到人的鞋框
- 即:未关联鞋框会直接跳过
1. `shoe_assoc` 之后会物理移除未选中的鞋框
- 被 `skip non_preferred`
- 未匹配
- 未被最终选中的 `shoe`
- 都不会再进入 `shoe_color / osd / alarm`
2. 脚部 ROI 改为按宽度自动居中
3. 鞋框几何筛选统一前置到 `shoe_assoc`
- 当前启用三层几何约束:
- `shoe / person`
- `shoe / roi`
- `shoe` 自身形状
4. `logic_gate` debug 日志已补充:
4. 鞋框形状判断改成前视/侧视两段式
- 前视鞋:`shoe_width / person_width < min_front_shoe_width_ratio`
- 前视上限:`max_front_shoe_aspect_ratio = 2.0`
- 侧视上限:`max_side_height_width_ratio = 1.2`
5. `logic_gate` debug 日志已补充:
- `person bbox`
- `foot_region`
- `skip unmatched shoe`
- `skip non_preferred shoe`
- `person_ratios`
- `roi_ratios`
- `aspect`
- `gates(person/roi/shape)`
6. 颜色分析从“平均亮度判定”演进到“中下部采样 + 三段亮度占比主导判定”
7. 将算法内部稳定值从 JSON 回收到程序默认值
- 鞋型语义参数
- 颜色判定内部常量
## 5. 人脸识别结果
@ -125,60 +183,144 @@
- `shoe_color` 早期会处理不该处理的鞋框
- 大鞋框或错误关联鞋框进入颜色判断后,容易把黑鞋判成 `non_black_shoe`
### 6.2 现阶段黑鞋结论
### 6.2 2026-04-14 至 2026-04-15 阶段性结果
在当前测试参数下,黑鞋误报已经明显下降,但多人场景仍存在少量误报。
#### 多人全黑鞋
设备侧日志表现为
设备侧日志结论
- 未关联鞋框会被 `skip unmatched shoe`
- 很多明显过大或过高的候选,在 `shoe_assoc` 阶段已经不再成为 `size_preferred=true`
- 主小人正常鞋框进入颜色分析后,多数结果为:
- `is_dark = true`
- 多人全黑鞋日志里,误报已从“大混合框”为主,收敛到“细长高框”和“接近 ROI 的偏大框”
- `color violation = 0`
- `ALARM = 0`
- `is_dark = false = 0`
- `is_dark = true = 42`
判断:
- 当前版本在多人全黑鞋场景下已基本无误报
- 当前主要进入颜色分析的是正常小鞋框
- 早期常见的“大双鞋 + 裤腿混合框”已基本不再进入告警链
#### 多人全白鞋
设备侧日志结论:
- `color violation = 57`
- `ALARM = 19`
- 真正触发告警的鞋框大多为正常小鞋框
- 典型比例范围:
- `person_width_ratio ≈ 0.15 ~ 0.31`
- `person_height_ratio ≈ 0.08 ~ 0.11`
- `person_area_ratio ≈ 0.012 ~ 0.032`
判断:
- 当前版本对白鞋仍能稳定告警
- 且不再主要依赖异常大框触发
#### 黑白混合多人
设备侧现象:
- 白鞋可正确告警
- 黑鞋误报比早期明显减少
- 后期残余误报主要来自:
- 浅色裤腿混入鞋框
- 亮地面或高亮背景混入鞋框
本轮采取的针对性修正包括:
- 颜色采样区改成鞋框中下部
- 颜色判定改成三段亮度占比主导,而不是只看平均亮度
- 大鞋框尺寸/面积上限整体收紧
阶段性判断:
- 当前这组前置几何筛选,对黑鞋误报收敛有效
- 但仍需继续收紧 `shoe / roi``aspect` 相关约束
- 当前“几何先收敛,再做亮度分布主导判定”的方向是有效的
- 黑白混合场景仍可能存在少量边界误差,但已不是主矛盾
### 6.3 现阶段白鞋结论
### 6.3 单人测试结果2026-04-15
在当前测试参数下,白鞋仍然可以稳定触发告警。
以下召回率为日志层面的粗估值,计算口径为:
设备侧日志表现为:
- `shoe selected / (shoe selected + no shoe selected)`
- 小而有效的白鞋框能保留下来
- `Brightness` 明显偏高,`is_dark = false`
- 可继续触发:
- `color violation`
- `RULE MATCHED`
- `ALARM`
该口径不是严格标注召回率,但适合作为联调阶段的横向比较指标。
同时,明显不合理的大框更多会在 `shoe_assoc` 阶段被压出优先候选。
#### 单人正面黑鞋
阶段性判断:
- `color violation = 0`
- `ALARM = 0`
- `is_dark = false = 0`
- `is_dark = true = 31`
- `shoe selected = 90`
- `no shoe selected = 59`
- 粗召回率约:`90 / (90 + 59) ≈ 60%`
- 当前这组参数没有把白鞋违规一起压没
判断:
- 正面黑鞋无误报
- 召回高于侧面场景
#### 单人侧面黑鞋
- `color violation = 0`
- `ALARM = 0`
- `is_dark = false = 0`
- `is_dark = true = 5`
- `shoe selected = 139`
- `no shoe selected = 134`
- 粗召回率约:`139 / (139 + 134) ≈ 51%`
判断:
- 侧面黑鞋无误报
- 但召回明显低于正面,当前主要瓶颈已转为几何过滤偏严
#### 单人侧面白鞋
- `color violation = 41`
- `ALARM = 18`
- `is_dark = false = 41`
- `is_dark = true = 8`
- `shoe selected = 181`
- `no shoe selected = 132`
- 粗召回率约:`181 / (181 + 132) ≈ 58%`
判断:
- 侧面白鞋以正确告警为主
- 召回略高于侧面黑鞋,但仍显示侧面场景整体召回偏低
## 7. 当前对尺寸过滤的结论
### 7.1 已验证结论
1. `max_shoe_height_ratio = 0.05`
- 过于严格
- 会把大量正常鞋框一起过滤掉
- 仅适合证明过滤链路是否生效,不适合作为正式值
1. 仅靠调颜色平均值不够
- 裤腿混入时,平均亮度会被浅色裤子拉高
- 亮地面混入时,底部采样又会被地面拉亮
- 当前改成“中下部采样 + 三段亮度占比主导”后明显更稳
2. 当前更平衡的测试值
- `max_shoe_height_ratio = 0.28`
- `max_shoe_width_ratio = 0.60`
- `max_shoe_area_ratio = 0.15`
2. 大双鞋框/裤腿混合框的主要问题在几何上限过宽
- 早期漏网大框典型值:
- `person_width_ratio ≈ 0.42 ~ 0.49`
- `person_height_ratio ≈ 0.17`
- `person_area_ratio ≈ 0.074 ~ 0.086`
- 当前正常单鞋框多落在:
- `person_width_ratio ≈ 0.15 ~ 0.31`
- `person_height_ratio ≈ 0.08 ~ 0.11`
- `person_area_ratio ≈ 0.012 ~ 0.032`
3. 面积比例比高度比例更关键
- `0.12` 时会压掉一部分有效白鞋框
- 调到 `0.15` 后,白鞋有效框放回了一部分
- 同时黑鞋明显误报暂未重新抬头
3. 现行收紧值已能明显切掉大混合框
- `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`
4. 当前剩余主要矛盾已不是误报,而是侧面场景召回
- 尤其单人侧面黑鞋,粗召回率约 `50%`
- 说明当前几何过滤对部分侧面鞋框偏严
### 7.2 当前三层几何约束设计
@ -197,37 +339,51 @@
几何筛选当前只属于 `shoe_assoc.person_shoe_check`,不再由 `shoe_color` 重复判断。
### 7.3 现阶段推荐测试值
### 7.3 当前推荐测试值
如果继续沿当前方向验证,建议先保持:
建议继续保持当前这组值进行单人/多人补测。
运行配置可调项:
- `foot_region.y_offset = 0.7`
- `foot_region.width_scale = 1.6`
- `foot_region.height_scale = 0.4`
- `min_shoe_height_ratio = 0.08`
- `min_shoe_area_ratio = 0.012`
- `max_shoe_height_ratio = 0.24`
- `max_shoe_width_ratio = 0.60`
- `max_shoe_area_ratio = 0.15`
- `max_shoe_roi_width_ratio = 0.65`
- `max_shoe_roi_height_ratio = 0.60`
- `max_shoe_roi_area_ratio = 0.25`
- `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`
程序内稳定默认值:
- `min_front_shoe_width_ratio = 0.18`
- `max_front_shoe_aspect_ratio = 2.0`
- `max_side_height_width_ratio = 1.2`
- `max_shoe_aspect_ratio = 2.0`
## 8. 下一步建议
下一步优先顺序建议如下:
1. 用同一组参数继续测多人视频
2. 补测不同距离的黑鞋/白鞋
3. 记录:
- 黑鞋是否再次出现误报
- 白鞋是否稳定告警
- 多人时是否出现串人、串鞋
4. 如果后续再调参数,优先围绕:
- `max_shoe_roi_height_ratio`
- `max_shoe_roi_area_ratio`
- `max_shoe_aspect_ratio`
- `max_shoe_height_ratio`
1. 继续用当前同一组参数补测更多单人视频
- 单人正面白鞋
- 单人远距离黑鞋
- 单人远距离白鞋
2. 保持当前多人黑鞋/白鞋/混合视频作为回归基线
3. 重点记录:
- 侧面黑鞋是否仍有明显漏检
- 侧面白鞋是否仍能稳定告警
- 大近景单鞋是否会被当前上限误杀
4. 如果后续继续调参数,优先围绕:
- `max_shoe_width_ratio`
- `max_shoe_area_ratio`
- `max_side_height_width_ratio`
- `min_shoe_area_ratio`
不建议在没有看清 `shoe / roi``aspect` 日志前,再继续单独调颜色阈值
当前不建议再单独调 `dark_threshold` 或重新切换采样区位置,应先把侧面召回问题看清。
### 8.1 建议补充的多人测试视频
@ -251,15 +407,19 @@
## 9. 现阶段结论
截至本记录时间点,可以做出的阶段性判断是:
截至 `2026-04-15` 当前阶段,可以做出的判断是:
- 人脸识别主链路已跑通
- 劳保鞋识别的数据流问题已定位并已做设备侧修正
- 当前测试参数下:
- 黑鞋误报明显下降
- 白鞋仍可触发告警
- `前置几何筛选 + 只处理已关联鞋框` 是当前阶段最有效的修正方向
- 当前剩余误报主要集中在:
- 细长高框
- 接近 ROI 的大混合框
- 少量远处小局部框
- 人脸识别主链路已跑通,当前主要调试重点仍是劳保鞋
- 劳保鞋这条链路当前的有效组合是:
- `前置几何筛选`
- `只保留已选中的鞋框继续下游流转`
- `中下部采样`
- `三段亮度占比主导判定`
- 当前版本在设备侧已表现为:
- 多人全黑鞋:无误报
- 多人全白鞋:可稳定告警
- 黑白混合:误报明显下降
- 单人正面黑鞋:无误报,粗召回约 `60%`
- 单人侧面黑鞋:无误报,粗召回约 `50%`
- 单人侧面白鞋:可告警,粗召回约 `58%`
- 当前主要剩余问题已从“误报过多”转为“侧面场景召回偏低”

View File

@ -14,9 +14,9 @@ enum class ColorMethod {
// 颜色分析配置
struct ColorConfig {
ColorMethod method = ColorMethod::HSV;
int dark_threshold = 80; // 深色阈值亮度0-255
float roi_expand = 1.0f; // ROI扩大系数
ColorMethod method = ColorMethod::BRIGHTNESS;
int dark_threshold = 90; // 回退判定使用的深色阈值亮度0-255
float roi_expand = 1.0f; // 颜色分析内部使用的ROI扩大系数
bool debug_output = false; // 是否输出调试信息
};

View File

@ -36,8 +36,8 @@ struct PersonShoeCheckConfig {
float max_shoe_roi_height_ratio = 0.60f;
float max_shoe_roi_area_ratio = 0.25f;
float min_front_shoe_width_ratio = 0.18f;
float max_front_shoe_aspect_ratio = 1.5f;
float max_side_height_width_ratio = 1.1f;
float max_front_shoe_aspect_ratio = 2.0f;
float max_side_height_width_ratio = 1.2f;
float max_shoe_aspect_ratio = 2.0f;
float match_iou = 0.02f;
float y_offset = 0.64f;
@ -215,17 +215,6 @@ private:
if (const SimpleJson* color = cfg.Find("color_check")) {
config.enable_color_check = color->ValueOr<bool>("enable", true);
const std::string method = color->ValueOr<std::string>("method", "hsv");
if (method == "hsv") config.color.method = ColorMethod::HSV;
else if (method == "rgb") config.color.method = ColorMethod::RGB;
else if (method == "brightness") config.color.method = ColorMethod::BRIGHTNESS;
else {
LogWarn("[logic_gate] unsupported color_check.method=" + method +
", disabling color analysis");
config.enable_color_check = false;
}
config.color.dark_threshold = color->ValueOr<int>("dark_threshold", 80);
config.color.roi_expand = color->ValueOr<float>("roi_expand", 1.0f);
config.color.debug_output = config.debug;
}
@ -261,14 +250,6 @@ private:
"max_shoe_roi_height_ratio", config.person_shoe.max_shoe_roi_height_ratio);
config.person_shoe.max_shoe_roi_area_ratio = ps->ValueOr<float>(
"max_shoe_roi_area_ratio", config.person_shoe.max_shoe_roi_area_ratio);
config.person_shoe.min_front_shoe_width_ratio = ps->ValueOr<float>(
"min_front_shoe_width_ratio", config.person_shoe.min_front_shoe_width_ratio);
config.person_shoe.max_front_shoe_aspect_ratio = ps->ValueOr<float>(
"max_front_shoe_aspect_ratio", config.person_shoe.max_front_shoe_aspect_ratio);
config.person_shoe.max_side_height_width_ratio = ps->ValueOr<float>(
"max_side_height_width_ratio", config.person_shoe.max_side_height_width_ratio);
config.person_shoe.max_shoe_aspect_ratio = ps->ValueOr<float>(
"max_shoe_aspect_ratio", config.person_shoe.max_shoe_aspect_ratio);
if (const SimpleJson* fr = ps->Find("foot_region"); fr && fr->IsObject()) {
config.person_shoe.y_offset = fr->ValueOr<float>("y_offset", config.person_shoe.y_offset);
config.person_shoe.width_scale = fr->ValueOr<float>("width_scale", config.person_shoe.width_scale);

View File

@ -6,8 +6,8 @@ namespace rk3588 {
struct PersonShoeShapeConfig {
float min_front_shoe_width_ratio = 0.18f;
float max_front_aspect_ratio = 1.5f;
float max_side_height_width_ratio = 1.1f;
float max_front_aspect_ratio = 2.0f;
float max_side_height_width_ratio = 1.2f;
};
struct PersonShoeShapeMetrics {