mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 23:33:05 +04:00
Merge pull request #28615 from Kumataro:fix28606
imgcodecs(png): support cICP metadata for imreadWithMetadata() #28615 Close https://github.com/opencv/opencv/issues/28606 Related https://github.com/opencv/opencv/pull/27741 (support for imwriteWithMetadata) ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
@@ -144,6 +144,17 @@ namespace opencv_test { namespace {
|
||||
return iccp_data;
|
||||
}
|
||||
|
||||
#ifdef OPENCV_IMGCODECS_PNG_WITH_cICP
|
||||
static std::vector<uchar> getSampleCicpData() {
|
||||
return {
|
||||
9, // BT.2020 / BT.2100
|
||||
16, // SMPTE ST 2084 (PQ)
|
||||
0, // Identity (RGB)
|
||||
1, // Full Range
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Test to check whether the EXIF orientation tag was processed successfully or not.
|
||||
* The test uses a set of 8 images named testExifOrientation_{1 to 8}.(extension).
|
||||
@@ -457,18 +468,27 @@ TEST(Imgcodecs_Png, Read_Write_With_Exif)
|
||||
EXPECT_EQ(img2.rows, img.rows);
|
||||
EXPECT_EQ(img2.type(), imgtype);
|
||||
EXPECT_EQ(read_metadata_types, read_metadata_types2);
|
||||
|
||||
#ifdef OPENCV_IMGCODECS_PNG_WITH_EXIF
|
||||
ASSERT_GE(read_metadata_types.size(), 1u);
|
||||
EXPECT_EQ(read_metadata, read_metadata2);
|
||||
EXPECT_EQ(read_metadata_types[0], IMAGE_METADATA_EXIF);
|
||||
EXPECT_EQ(read_metadata_types.size(), read_metadata.size());
|
||||
EXPECT_EQ(read_metadata[0], metadata[0]);
|
||||
#else
|
||||
ASSERT_GE(read_metadata_types.size(), 0u);
|
||||
#endif
|
||||
EXPECT_EQ(cv::norm(img2, img3, NORM_INF), 0.);
|
||||
double mse = cv::norm(img, img2, NORM_L2SQR)/(img.rows*img.cols);
|
||||
EXPECT_EQ(mse, 0); // png is lossless
|
||||
remove(outputname.c_str());
|
||||
}
|
||||
|
||||
#ifdef OPENCV_IMGCODECS_PNG_WITH_cICP
|
||||
TEST(Imgcodecs_Png, Read_Write_With_Exif_Xmp_Iccp_cICP)
|
||||
#else
|
||||
TEST(Imgcodecs_Png, Read_Write_With_Exif_Xmp_Iccp)
|
||||
#endif
|
||||
{
|
||||
int png_compression = 3;
|
||||
int imgtype = CV_MAKETYPE(CV_8U, 3);
|
||||
@@ -482,6 +502,11 @@ TEST(Imgcodecs_Png, Read_Write_With_Exif_Xmp_Iccp)
|
||||
getSampleIccpData(),
|
||||
};
|
||||
|
||||
#ifdef OPENCV_IMGCODECS_PNG_WITH_cICP
|
||||
metadata_types.push_back(IMAGE_METADATA_CICP);
|
||||
metadata.push_back(getSampleCicpData());
|
||||
#endif
|
||||
|
||||
std::vector<int> write_params = {
|
||||
IMWRITE_PNG_COMPRESSION, png_compression
|
||||
};
|
||||
@@ -498,9 +523,23 @@ TEST(Imgcodecs_Png, Read_Write_With_Exif_Xmp_Iccp)
|
||||
EXPECT_EQ(img2.rows, img.rows);
|
||||
EXPECT_EQ(img2.type(), imgtype);
|
||||
|
||||
#ifdef OPENCV_IMGCODECS_PNG_WITH_EXIF
|
||||
EXPECT_EQ(metadata_types, read_metadata_types);
|
||||
EXPECT_EQ(read_metadata_types, read_metadata_types2);
|
||||
EXPECT_EQ(metadata, read_metadata);
|
||||
#else
|
||||
ASSERT_GE(read_metadata_types.size(), 2u);
|
||||
EXPECT_EQ(read_metadata_types[0], IMAGE_METADATA_XMP);
|
||||
EXPECT_EQ(read_metadata_types[1], IMAGE_METADATA_ICCP);
|
||||
|
||||
ASSERT_GE(read_metadata_types2.size(), 2u);
|
||||
EXPECT_EQ(read_metadata_types2[0], IMAGE_METADATA_XMP);
|
||||
EXPECT_EQ(read_metadata_types2[1], IMAGE_METADATA_ICCP);
|
||||
|
||||
ASSERT_GE(read_metadata.size(), 2u);
|
||||
EXPECT_EQ(metadata[1], read_metadata[0]);
|
||||
EXPECT_EQ(metadata[2], read_metadata[1]);
|
||||
#endif
|
||||
remove(outputname.c_str());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user