Remove fallback from shoe selection and color analysis
This commit is contained in:
parent
6a4b471831
commit
a08dbdf62a
@ -68,10 +68,15 @@ ColorResult ColorAnalyzer::Analyze(const Frame& frame, const Rect& bbox) {
|
||||
result = AnalyzeBrightness(center.data(), inner_w, inner_h, 3);
|
||||
break;
|
||||
default:
|
||||
result = AnalyzeHSV(center.data(), inner_w, inner_h, 3);
|
||||
LogWarn("[ColorAnalyzer] Unsupported color method: " +
|
||||
std::to_string(static_cast<int>(config_.method)));
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (!result.valid) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// 判断是否为劳保鞋颜色
|
||||
result.is_dark = IsSafetyBootsColor(result);
|
||||
|
||||
@ -184,6 +189,7 @@ ColorResult ColorAnalyzer::AnalyzeHSV(const uint8_t* data, int w, int h, int cha
|
||||
result.dark_ratio = dark_pixels / static_cast<float>(total_pixels);
|
||||
result.light_ratio = 1.0f - result.dark_ratio;
|
||||
result.confidence = result.dark_ratio;
|
||||
result.valid = true;
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -213,6 +219,7 @@ ColorResult ColorAnalyzer::AnalyzeRGB(const uint8_t* data, int w, int h, int cha
|
||||
result.dark_ratio = dark_pixels / static_cast<float>(total_pixels);
|
||||
result.light_ratio = 1.0f - result.dark_ratio;
|
||||
result.confidence = result.dark_ratio;
|
||||
result.valid = true;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -24,6 +24,7 @@ struct ColorConfig {
|
||||
|
||||
// 颜色分析结果
|
||||
struct ColorResult {
|
||||
bool valid = false; // 分析结果是否有效
|
||||
bool is_dark = false; // 是否为深色
|
||||
float brightness = 0.0f; // 平均亮度(0-255)
|
||||
float confidence = 0.0f; // 置信度
|
||||
|
||||
@ -200,6 +200,11 @@ private:
|
||||
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.center_w_scale = color->ValueOr<float>("center_w_scale", 0.6f);
|
||||
@ -384,12 +389,21 @@ private:
|
||||
" match_score=" + std::to_string(match_score));
|
||||
}
|
||||
if (!pass_gate) continue;
|
||||
if (config_.person_shoe.enable_size_preferred && !size_preferred) {
|
||||
if (config_.debug) {
|
||||
LogInfo("[logic_gate] skip non_preferred shoe person_track=" +
|
||||
std::to_string(person.track_id) +
|
||||
" det_idx=" + std::to_string(static_cast<int>(shoe_indices[si])) +
|
||||
" bbox=(" + std::to_string(static_cast<int>(shoe.bbox.x)) + "," +
|
||||
std::to_string(static_cast<int>(shoe.bbox.y)) + "," +
|
||||
std::to_string(static_cast<int>(shoe.bbox.w)) + "," +
|
||||
std::to_string(static_cast<int>(shoe.bbox.h)) + ")");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
++candidate_count;
|
||||
const bool should_replace =
|
||||
best_shoe_local < 0 ||
|
||||
(size_preferred && !best_size_preferred) ||
|
||||
(size_preferred == best_size_preferred && match_score > best_match_score);
|
||||
const bool should_replace = best_shoe_local < 0 || match_score > best_match_score;
|
||||
if (should_replace) {
|
||||
best_shoe_local = static_cast<int>(si);
|
||||
best_match_score = match_score;
|
||||
@ -479,6 +493,13 @@ private:
|
||||
|
||||
const Rect mapped_bbox = MapDetCoordToFrame(boot.bbox, frame);
|
||||
const auto color_result = color_analyzer_->Analyze(*frame, mapped_bbox);
|
||||
if (!color_result.valid) {
|
||||
if (config_.debug) {
|
||||
LogInfo("[logic_gate] skip invalid color result track_id=" +
|
||||
std::to_string(boot.track_id));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (color_result.is_dark) continue;
|
||||
|
||||
Detection no_boots_det;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user