Updated tests in face_landmarker_result_converter_test

This commit is contained in:
Kinar 2023-12-11 16:11:39 -08:00
parent 0200d32285
commit 42b251cb8d

View File

@ -52,8 +52,7 @@ void InitFaceLandmarkerResult(
cpp_result->face_blendshapes =
std::vector<mediapipe::tasks::components::containers::Classifications>{
classifications_for_blendshapes};
// cpp_result->face_blendshapes->push_back(
// classifications_for_blendshapes);
cpp_result->face_blendshapes->push_back(classifications_for_blendshapes);
// Initialize facial_transformation_matrixes
Eigen::MatrixXf cpp_matrix(2, 2);
@ -86,7 +85,6 @@ TEST(FaceLandmarkerResultConverterTest, ConvertsCustomResult) {
}
// Verify conversion of face_blendshapes
if (cpp_result.face_blendshapes.has_value()) {
EXPECT_EQ(c_result.face_blendshapes_count,
cpp_result.face_blendshapes.value().size());
for (uint32_t i = 0; i < c_result.face_blendshapes_count; ++i) {
@ -100,19 +98,16 @@ TEST(FaceLandmarkerResultConverterTest, ConvertsCustomResult) {
cpp_category.index);
EXPECT_FLOAT_EQ(c_result.face_blendshapes[i].categories[j].score,
cpp_category.score);
EXPECT_EQ(std::string(
c_result.face_blendshapes[i].categories[j].category_name),
EXPECT_EQ(
std::string(c_result.face_blendshapes[i].categories[j].category_name),
cpp_category.category_name);
}
}
}
// Verify conversion of facial_transformation_matrixes
if (cpp_result.facial_transformation_matrixes.has_value()) {
EXPECT_EQ(c_result.facial_transformation_matrixes_count,
cpp_result.facial_transformation_matrixes.value().size());
for (uint32_t i = 0; i < c_result.facial_transformation_matrixes_count;
++i) {
for (uint32_t i = 0; i < c_result.facial_transformation_matrixes_count; ++i) {
const auto& cpp_facial_transformation_matrixes =
cpp_result.facial_transformation_matrixes.value();
// Assuming Matrix struct contains data array and dimensions
@ -125,13 +120,11 @@ TEST(FaceLandmarkerResultConverterTest, ConvertsCustomResult) {
for (long row = 0; row < cpp_matrix.rows(); ++row) {
for (long col = 0; col < cpp_matrix.cols(); ++col) {
size_t index = col * cpp_matrix.rows() + row; // Column-major index
EXPECT_FLOAT_EQ(
c_result.facial_transformation_matrixes[i].data[index],
EXPECT_FLOAT_EQ(c_result.facial_transformation_matrixes[i].data[index],
cpp_matrix(row, col));
}
}
}
}
CppCloseFaceLandmarkerResult(&c_result);
}