Fix crash in SavePngTestOutput

Do not call SavePngTestOutput in CompareAndSaveImageOutput in case diff_img is null. This can happen if for instance the expected and the actual image have non-matching format or size. Currently, this crashes.
Support single channel golden images.

PiperOrigin-RevId: 552519834
This commit is contained in:
MediaPipe Team 2023-07-31 10:18:06 -07:00 committed by Copybara-Service
parent d392f8ad98
commit 6f916a001c

View File

@ -228,7 +228,9 @@ absl::Status CompareAndSaveImageOutput(
auto status = CompareImageFrames(**expected, actual, options.max_color_diff,
options.max_alpha_diff, options.max_avg_diff,
diff_img);
ASSIGN_OR_RETURN(auto diff_img_path, SavePngTestOutput(*diff_img, "diff"));
if (diff_img) {
ASSIGN_OR_RETURN(auto diff_img_path, SavePngTestOutput(*diff_img, "diff"));
}
return status;
}