Updated tests in face_landmarker_result_converter_test
This commit is contained in:
		
							parent
							
								
									0200d32285
								
							
						
					
					
						commit
						42b251cb8d
					
				| 
						 | 
					@ -52,8 +52,7 @@ void InitFaceLandmarkerResult(
 | 
				
			||||||
  cpp_result->face_blendshapes =
 | 
					  cpp_result->face_blendshapes =
 | 
				
			||||||
      std::vector<mediapipe::tasks::components::containers::Classifications>{
 | 
					      std::vector<mediapipe::tasks::components::containers::Classifications>{
 | 
				
			||||||
          classifications_for_blendshapes};
 | 
					          classifications_for_blendshapes};
 | 
				
			||||||
  //  cpp_result->face_blendshapes->push_back(
 | 
					  cpp_result->face_blendshapes->push_back(classifications_for_blendshapes);
 | 
				
			||||||
  //      classifications_for_blendshapes);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Initialize facial_transformation_matrixes
 | 
					  // Initialize facial_transformation_matrixes
 | 
				
			||||||
  Eigen::MatrixXf cpp_matrix(2, 2);
 | 
					  Eigen::MatrixXf cpp_matrix(2, 2);
 | 
				
			||||||
| 
						 | 
					@ -86,7 +85,6 @@ TEST(FaceLandmarkerResultConverterTest, ConvertsCustomResult) {
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Verify conversion of face_blendshapes
 | 
					  // Verify conversion of face_blendshapes
 | 
				
			||||||
  if (cpp_result.face_blendshapes.has_value()) {
 | 
					 | 
				
			||||||
  EXPECT_EQ(c_result.face_blendshapes_count,
 | 
					  EXPECT_EQ(c_result.face_blendshapes_count,
 | 
				
			||||||
            cpp_result.face_blendshapes.value().size());
 | 
					            cpp_result.face_blendshapes.value().size());
 | 
				
			||||||
  for (uint32_t i = 0; i < c_result.face_blendshapes_count; ++i) {
 | 
					  for (uint32_t i = 0; i < c_result.face_blendshapes_count; ++i) {
 | 
				
			||||||
| 
						 | 
					@ -100,19 +98,16 @@ TEST(FaceLandmarkerResultConverterTest, ConvertsCustomResult) {
 | 
				
			||||||
                cpp_category.index);
 | 
					                cpp_category.index);
 | 
				
			||||||
      EXPECT_FLOAT_EQ(c_result.face_blendshapes[i].categories[j].score,
 | 
					      EXPECT_FLOAT_EQ(c_result.face_blendshapes[i].categories[j].score,
 | 
				
			||||||
                      cpp_category.score);
 | 
					                      cpp_category.score);
 | 
				
			||||||
        EXPECT_EQ(std::string(
 | 
					      EXPECT_EQ(
 | 
				
			||||||
                      c_result.face_blendshapes[i].categories[j].category_name),
 | 
					          std::string(c_result.face_blendshapes[i].categories[j].category_name),
 | 
				
			||||||
          cpp_category.category_name);
 | 
					          cpp_category.category_name);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Verify conversion of facial_transformation_matrixes
 | 
					  // Verify conversion of facial_transformation_matrixes
 | 
				
			||||||
  if (cpp_result.facial_transformation_matrixes.has_value()) {
 | 
					 | 
				
			||||||
  EXPECT_EQ(c_result.facial_transformation_matrixes_count,
 | 
					  EXPECT_EQ(c_result.facial_transformation_matrixes_count,
 | 
				
			||||||
            cpp_result.facial_transformation_matrixes.value().size());
 | 
					            cpp_result.facial_transformation_matrixes.value().size());
 | 
				
			||||||
    for (uint32_t i = 0; i < c_result.facial_transformation_matrixes_count;
 | 
					  for (uint32_t i = 0; i < c_result.facial_transformation_matrixes_count; ++i) {
 | 
				
			||||||
         ++i) {
 | 
					 | 
				
			||||||
    const auto& cpp_facial_transformation_matrixes =
 | 
					    const auto& cpp_facial_transformation_matrixes =
 | 
				
			||||||
        cpp_result.facial_transformation_matrixes.value();
 | 
					        cpp_result.facial_transformation_matrixes.value();
 | 
				
			||||||
    // Assuming Matrix struct contains data array and dimensions
 | 
					    // 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 row = 0; row < cpp_matrix.rows(); ++row) {
 | 
				
			||||||
      for (long col = 0; col < cpp_matrix.cols(); ++col) {
 | 
					      for (long col = 0; col < cpp_matrix.cols(); ++col) {
 | 
				
			||||||
        size_t index = col * cpp_matrix.rows() + row;  // Column-major index
 | 
					        size_t index = col * cpp_matrix.rows() + row;  // Column-major index
 | 
				
			||||||
          EXPECT_FLOAT_EQ(
 | 
					        EXPECT_FLOAT_EQ(c_result.facial_transformation_matrixes[i].data[index],
 | 
				
			||||||
              c_result.facial_transformation_matrixes[i].data[index],
 | 
					 | 
				
			||||||
                        cpp_matrix(row, col));
 | 
					                        cpp_matrix(row, col));
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  CppCloseFaceLandmarkerResult(&c_result);
 | 
					  CppCloseFaceLandmarkerResult(&c_result);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user