41 lines
1.3 KiB
C++
41 lines
1.3 KiB
C++
#pragma once
|
|
|
|
#include <algorithm>
|
|
|
|
namespace rk3588 {
|
|
|
|
struct PersonShoeShapeConfig {
|
|
float min_front_shoe_width_ratio = 0.18f;
|
|
float max_front_aspect_ratio = 2.0f;
|
|
float max_side_height_width_ratio = 1.2f;
|
|
};
|
|
|
|
struct PersonShoeShapeMetrics {
|
|
float person_width_ratio = 0.0f;
|
|
float aspect_ratio = 0.0f;
|
|
bool is_front_view = false;
|
|
bool shape_gate = false;
|
|
};
|
|
|
|
inline PersonShoeShapeMetrics EvaluatePersonShoeShape(float shoe_w,
|
|
float shoe_h,
|
|
float person_w,
|
|
const PersonShoeShapeConfig& config) {
|
|
PersonShoeShapeMetrics m;
|
|
const float safe_person_w = std::max(1.0f, person_w);
|
|
const float safe_shoe_w = std::max(1.0f, shoe_w);
|
|
const float safe_shoe_h = std::max(1.0f, shoe_h);
|
|
|
|
m.person_width_ratio = safe_shoe_w / safe_person_w;
|
|
m.aspect_ratio = safe_shoe_h / safe_shoe_w;
|
|
m.is_front_view = m.person_width_ratio < config.min_front_shoe_width_ratio;
|
|
if (m.is_front_view) {
|
|
m.shape_gate = m.aspect_ratio <= config.max_front_aspect_ratio;
|
|
} else {
|
|
m.shape_gate = safe_shoe_h <= (safe_shoe_w * config.max_side_height_width_ratio);
|
|
}
|
|
return m;
|
|
}
|
|
|
|
} // namespace rk3588
|