From ebbe70e076da5452f8f30509960541eec99b2a12 Mon Sep 17 00:00:00 2001 From: tian <11429339@qq.com> Date: Tue, 14 Apr 2026 11:30:37 +0800 Subject: [PATCH] Add minimum shoe box constraints --- configs/full_pipeline_1080p_test_alarm.json | 6 +++++- plugins/logic_gate/logic_gate_node.cpp | 18 ++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/configs/full_pipeline_1080p_test_alarm.json b/configs/full_pipeline_1080p_test_alarm.json index 1873e8a..2510d15 100644 --- a/configs/full_pipeline_1080p_test_alarm.json +++ b/configs/full_pipeline_1080p_test_alarm.json @@ -228,6 +228,8 @@ "height_scale": 0.58 }, "enable_size_preferred": true, + "min_shoe_height_ratio": 0.06, + "min_shoe_area_ratio": 0.01, "max_shoe_height_ratio": 0.28, "max_shoe_width_ratio": 0.6, "max_shoe_area_ratio": 0.15 @@ -252,6 +254,8 @@ "dark_threshold": 90, "roi_expand": 1.0, "enable_size_filter": true, + "min_shoe_height_ratio": 0.06, + "min_shoe_area_ratio": 0.01, "max_shoe_height_ratio": 0.28, "max_shoe_width_ratio": 0.6, "max_shoe_area_ratio": 0.15 @@ -528,4 +532,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/plugins/logic_gate/logic_gate_node.cpp b/plugins/logic_gate/logic_gate_node.cpp index a623088..2e1f17c 100644 --- a/plugins/logic_gate/logic_gate_node.cpp +++ b/plugins/logic_gate/logic_gate_node.cpp @@ -24,6 +24,8 @@ struct PersonShoeCheckConfig { bool attach_person_track_to_shoe = true; bool emit_missing_violation = true; bool enable_size_preferred = false; + float min_shoe_height_ratio = 0.06f; + float min_shoe_area_ratio = 0.01f; float max_shoe_height_ratio = 0.28f; float max_shoe_width_ratio = 0.60f; float max_shoe_area_ratio = 0.15f; @@ -41,6 +43,8 @@ struct LogicGateConfig { int violation_class = 10; bool enable_color_check = true; bool enable_size_filter = false; + float min_shoe_height_ratio = 0.06f; + float min_shoe_area_ratio = 0.01f; float max_shoe_height_ratio = 1.0f / 6.0f; float max_shoe_width_ratio = 1.0f; float max_shoe_area_ratio = 0.15f; @@ -145,6 +149,8 @@ private: config.color.center_w_scale = color->ValueOr("center_w_scale", 0.6f); config.color.center_h_scale = color->ValueOr("center_h_scale", 0.6f); config.enable_size_filter = color->ValueOr("enable_size_filter", false); + config.min_shoe_height_ratio = color->ValueOr("min_shoe_height_ratio", config.min_shoe_height_ratio); + config.min_shoe_area_ratio = color->ValueOr("min_shoe_area_ratio", config.min_shoe_area_ratio); config.max_shoe_height_ratio = color->ValueOr("max_shoe_height_ratio", config.max_shoe_height_ratio); config.max_shoe_width_ratio = color->ValueOr("max_shoe_width_ratio", config.max_shoe_width_ratio); config.max_shoe_area_ratio = color->ValueOr("max_shoe_area_ratio", config.max_shoe_area_ratio); @@ -167,6 +173,10 @@ private: 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( + "min_shoe_area_ratio", config.person_shoe.min_shoe_area_ratio); config.person_shoe.max_shoe_height_ratio = ps->ValueOr( "max_shoe_height_ratio", config.person_shoe.max_shoe_height_ratio); config.person_shoe.max_shoe_width_ratio = ps->ValueOr( @@ -278,7 +288,9 @@ private: const float height_ratio = shoe.bbox.h / std::max(1.0f, person.bbox.h); const float area_ratio = (shoe.bbox.w * shoe.bbox.h) / person_area; const bool size_preferred = !config_.person_shoe.enable_size_preferred || - (width_ratio <= config_.person_shoe.max_shoe_width_ratio && + (height_ratio >= config_.person_shoe.min_shoe_height_ratio && + area_ratio >= config_.person_shoe.min_shoe_area_ratio && + width_ratio <= config_.person_shoe.max_shoe_width_ratio && height_ratio <= config_.person_shoe.max_shoe_height_ratio && area_ratio <= config_.person_shoe.max_shoe_area_ratio); const float match_score = shoe.score * 10.0f + (center_inside ? 1.0f : 0.0f) + iou; @@ -407,7 +419,9 @@ private: const float width_ratio = boot.bbox.w / std::max(1.0f, person_bbox.w); const float height_ratio = boot.bbox.h / std::max(1.0f, person_bbox.h); const float area_ratio = (boot.bbox.w * boot.bbox.h) / person_area; - if (width_ratio > config_.max_shoe_width_ratio || + if (height_ratio < config_.min_shoe_height_ratio || + area_ratio < config_.min_shoe_area_ratio || + width_ratio > config_.max_shoe_width_ratio || height_ratio > config_.max_shoe_height_ratio || area_ratio > config_.max_shoe_area_ratio) { if (config_.debug) {