Internal change
PiperOrigin-RevId: 516179167
|
@ -138,7 +138,23 @@ void TestWithAspectRatio(const double aspect_ratio,
|
||||||
std::string result_image;
|
std::string result_image;
|
||||||
MP_ASSERT_OK(
|
MP_ASSERT_OK(
|
||||||
mediapipe::file::GetContents(result_string_path, &result_image));
|
mediapipe::file::GetContents(result_string_path, &result_image));
|
||||||
EXPECT_EQ(result_image, output_string);
|
if (result_image != output_string) {
|
||||||
|
// There may be slight differences due to the way the JPEG was encoded or
|
||||||
|
// the OpenCV version used to generate the reference files. Compare
|
||||||
|
// pixel-by-pixel using the Peak Signal-to-Noise Ratio instead.
|
||||||
|
cv::Mat result_mat =
|
||||||
|
cv::imdecode(cv::Mat(1, result_image.size(), CV_8UC1,
|
||||||
|
const_cast<char*>(result_image.data())),
|
||||||
|
cv::IMREAD_UNCHANGED);
|
||||||
|
cv::Mat output_mat =
|
||||||
|
cv::imdecode(cv::Mat(1, output_string.size(), CV_8UC1,
|
||||||
|
const_cast<char*>(output_string.data())),
|
||||||
|
cv::IMREAD_UNCHANGED);
|
||||||
|
ASSERT_EQ(result_mat.rows, output_mat.rows);
|
||||||
|
ASSERT_EQ(result_mat.cols, output_mat.cols);
|
||||||
|
ASSERT_EQ(result_mat.type(), output_mat.type());
|
||||||
|
EXPECT_GT(cv::PSNR(result_mat, output_mat), 45.0);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
std::string output_string_path = mediapipe::file::JoinPath(
|
std::string output_string_path = mediapipe::file::JoinPath(
|
||||||
absl::GetFlag(FLAGS_output_folder),
|
absl::GetFlag(FLAGS_output_folder),
|
||||||
|
|
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 6.1 KiB |
Before Width: | Height: | Size: 8.2 KiB After Width: | Height: | Size: 8.2 KiB |
Before Width: | Height: | Size: 7.6 KiB After Width: | Height: | Size: 7.6 KiB |