Enable PNG exif orientation test#26181
Conversation
|
RFC : . |
modules/imgcodecs/test/test_png.cpp
Outdated
| EXPECT_LE(vec.val[1], colorThresholdLow); | ||
| EXPECT_LE(vec.val[2], colorThresholdLow); | ||
|
|
||
| m_img = imread(filename, IMREAD_ADD_ALPHA); |
There was a problem hiding this comment.
The test itself is still disabled.
There was a problem hiding this comment.
when
m_img = imread(filename, IMREAD_ANYCOLOR);
ASSERT_FALSE(m_img.empty());
EXPECT_EQ(4, m_img.channels());
**the test fails **
[----------] 8 tests from ExifFiles/Imgcodecs_PNG_Exif
[ RUN ] ExifFiles/Imgcodecs_PNG_Exif.exif_orientation/0, where GetParam() = "readwrite/testExifOrientation_1.png"
C:\build\precommit_windows64\4.x\opencv\modules\imgcodecs\test\test_png.cpp(191): error: Expected equality of these values:
4
m_img.channels()
Which is: 3
C:\build\precommit_windows64\4.x\opencv\modules\imgcodecs\test\test_png.cpp(196): error: Expected: (vec4.val[0]) <= (colorThresholdLow), actual: '\xFE' (254) vs 5
C:\build\precommit_windows64\4.x\opencv\modules\imgcodecs\test\test_png.cpp(198): error: Expected: (vec4.val[2]) >= (colorThresholdHigh), actual: '\0' vs 250
C:\build\precommit_windows64\4.x\opencv\modules\imgcodecs\test\test_png.cpp(202): error: Expected: (vec4.val[0]) <= (colorThresholdLow), actual: '\xFF' (255) vs 5
C:\build\precommit_windows64\4.x\opencv\modules\imgcodecs\test\test_png.cpp(203): error: Expected: (vec4.val[1]) >= (colorThresholdHigh), actual: '\0' vs 250
C:\build\precommit_windows64\4.x\opencv\modules\imgcodecs\test\test_png.cpp(208): error: Expected: (vec4.val[0]) >= (colorThresholdHigh), actual: '\x2' (2) vs 250
C:\build\precommit_windows64\4.x\opencv\modules\imgcodecs\test\test_png.cpp(209): error: Expected: (vec4.val[1]) <= (colorThresholdLow), actual: '\xFD' (253) vs 5
[ FAILED ] ExifFiles/Imgcodecs_PNG_Exif.exif_orientation/0, where GetParam() = "readwrite/testExifOrientation_1.png" (2 ms)
[ RUN ] ExifFiles/Imgcodecs_PNG_Exif.exif_orientation/1, where GetParam() = "readwrite/testExifOrientation_2.png"
C:\build\precommit_windows64\4.x\opencv\modules\imgcodecs\test\test_png.cpp(191): error: Expected equality of these values:
4
m_img.channels()
Which is: 3
modules/imgcodecs/src/loadsave.cpp
Outdated
|
|
||
| static inline int calcType(int type, int flags) | ||
| { | ||
| if (flags == IMREAD_ADD_ALPHA) |
There was a problem hiding this comment.
There is cv::IMREAD_ANYCOLOR option. It should presume alpha channel, if it's present in the original image.
fc31853 to
05dcdae
Compare
05dcdae to
48a48fe
Compare
|
as stated in the test code I think this is acceptable until something better is done. |
| * The flags parameter of the imread function is set as IMREAD_COLOR | IMREAD_ANYCOLOR | IMREAD_ANYDEPTH. | ||
| * Using this combination is an undocumented trick to load images similarly to the IMREAD_UNCHANGED flag, | ||
| * preserving the alpha channel (if present) while also applying the orientation. | ||
| */ |
There was a problem hiding this comment.
I propose to add it to documentation.
Pull Request Readiness Checklist
related to #23122
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.