Add minimum shoe box constraints

This commit is contained in:
tian 2026-04-14 11:30:37 +08:00
parent dd5ff851fb
commit ebbe70e076
2 changed files with 21 additions and 3 deletions

View File

@ -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

View File

@ -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<float>("center_w_scale", 0.6f);
config.color.center_h_scale = color->ValueOr<float>("center_h_scale", 0.6f);
config.enable_size_filter = color->ValueOr<bool>("enable_size_filter", false);
config.min_shoe_height_ratio = color->ValueOr<float>("min_shoe_height_ratio", config.min_shoe_height_ratio);
config.min_shoe_area_ratio = color->ValueOr<float>("min_shoe_area_ratio", config.min_shoe_area_ratio);
config.max_shoe_height_ratio = color->ValueOr<float>("max_shoe_height_ratio", config.max_shoe_height_ratio);
config.max_shoe_width_ratio = color->ValueOr<float>("max_shoe_width_ratio", config.max_shoe_width_ratio);
config.max_shoe_area_ratio = color->ValueOr<float>("max_shoe_area_ratio", config.max_shoe_area_ratio);
@ -167,6 +173,10 @@ private:
config.person_shoe.match_iou = ps->ValueOr<float>("match_iou", config.person_shoe.match_iou);
config.person_shoe.enable_size_preferred = ps->ValueOr<bool>(
"enable_size_preferred", config.person_shoe.enable_size_preferred);
config.person_shoe.min_shoe_height_ratio = ps->ValueOr<float>(
"min_shoe_height_ratio", config.person_shoe.min_shoe_height_ratio);
config.person_shoe.min_shoe_area_ratio = ps->ValueOr<float>(
"min_shoe_area_ratio", config.person_shoe.min_shoe_area_ratio);
config.person_shoe.max_shoe_height_ratio = ps->ValueOr<float>(
"max_shoe_height_ratio", config.person_shoe.max_shoe_height_ratio);
config.person_shoe.max_shoe_width_ratio = ps->ValueOr<float>(
@ -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) {