OrangePi3588Media/tests/test_person_shoe_shape.cpp

77 lines
2.4 KiB
C++

#include <gtest/gtest.h>
#include "../plugins/logic_gate/person_shoe_shape.h"
namespace rk3588 {
namespace {
TEST(PersonShoeShapeTest, RejectsTallSideViewBoxes) {
PersonShoeShapeConfig config;
config.min_front_shoe_width_ratio = 0.18f;
config.max_front_aspect_ratio = 1.5f;
config.max_side_height_width_ratio = 0.8f;
const auto metrics = EvaluatePersonShoeShape(20.0f, 33.0f, 100.0f, config);
EXPECT_FALSE(metrics.is_front_view);
EXPECT_FALSE(metrics.shape_gate);
EXPECT_FLOAT_EQ(metrics.person_width_ratio, 0.2f);
EXPECT_FLOAT_EQ(metrics.aspect_ratio, 1.65f);
}
TEST(PersonShoeShapeTest, AllowsSlightlyTallFrontViewBoxes) {
PersonShoeShapeConfig config;
config.min_front_shoe_width_ratio = 0.18f;
config.max_front_aspect_ratio = 1.5f;
config.max_side_height_width_ratio = 0.8f;
const auto metrics = EvaluatePersonShoeShape(16.0f, 24.0f, 100.0f, config);
EXPECT_TRUE(metrics.is_front_view);
EXPECT_TRUE(metrics.shape_gate);
EXPECT_FLOAT_EQ(metrics.person_width_ratio, 0.16f);
EXPECT_FLOAT_EQ(metrics.aspect_ratio, 1.5f);
}
TEST(PersonShoeShapeTest, RejectsFrontViewBoxesBeyondAllowedAspect) {
PersonShoeShapeConfig config;
config.min_front_shoe_width_ratio = 0.18f;
config.max_front_aspect_ratio = 1.5f;
config.max_side_height_width_ratio = 0.8f;
const auto metrics = EvaluatePersonShoeShape(16.0f, 25.0f, 100.0f, config);
EXPECT_TRUE(metrics.is_front_view);
EXPECT_FALSE(metrics.shape_gate);
EXPECT_FLOAT_EQ(metrics.aspect_ratio, 1.5625f);
}
TEST(PersonShoeShapeTest, AllowsWideSideViewBoxes) {
PersonShoeShapeConfig config;
config.min_front_shoe_width_ratio = 0.18f;
config.max_front_aspect_ratio = 1.5f;
config.max_side_height_width_ratio = 0.8f;
const auto metrics = EvaluatePersonShoeShape(40.0f, 24.0f, 100.0f, config);
EXPECT_FALSE(metrics.is_front_view);
EXPECT_TRUE(metrics.shape_gate);
EXPECT_FLOAT_EQ(metrics.aspect_ratio, 0.6f);
}
TEST(PersonShoeShapeTest, RejectsNearSquareSideViewBoxes) {
PersonShoeShapeConfig config;
config.min_front_shoe_width_ratio = 0.18f;
config.max_front_aspect_ratio = 1.5f;
config.max_side_height_width_ratio = 0.8f;
const auto metrics = EvaluatePersonShoeShape(40.0f, 33.0f, 100.0f, config);
EXPECT_FALSE(metrics.is_front_view);
EXPECT_FALSE(metrics.shape_gate);
EXPECT_FLOAT_EQ(metrics.aspect_ratio, 0.825f);
}
} // namespace
} // namespace rk3588