-
-
Notifications
You must be signed in to change notification settings - Fork 56.2k
imgcodecs: OpenEXR multispectral read/write support #27485
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
292ca1d
3b8f1d0
1103a0d
f8c2f76
fb73fe9
a8320fb
ca820ad
b30f59b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,6 +68,32 @@ TEST(Imgcodecs_EXR, readWrite_32FC3) | |
EXPECT_EQ(0, remove(filenameOutput.c_str())); | ||
} | ||
|
||
TEST(Imgcodecs_EXR, readWrite_32FC7) | ||
{ // 0-6 channels (nultispectral) | ||
const string root = cvtest::TS::ptr()->get_data_path(); | ||
const string filenameInput = root + "readwrite/test32FC7.exr"; | ||
const string filenameOutput = cv::tempfile(".exr"); | ||
#ifndef GENERATE_DATA | ||
const Mat img = cv::imread(filenameInput, IMREAD_UNCHANGED); | ||
asmorkalov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#else | ||
const Size sz(3, 5); | ||
Mat img(sz, CV_32FC7); | ||
img.at<cv::Vec<float, 7>>(0, 0)[0] = 101.125; | ||
img.at<cv::Vec<float, 7>>(2, 1)[3] = 203.500; | ||
img.at<cv::Vec<float, 7>>(4, 2)[6] = 305.875; | ||
ASSERT_TRUE(cv::imwrite(filenameInput, img)); | ||
#endif | ||
ASSERT_FALSE(img.empty()); | ||
ASSERT_EQ(CV_MAKETYPE(CV_32F, 7), img.type()); | ||
|
||
ASSERT_TRUE(cv::imwrite(filenameOutput, img)); | ||
const Mat img2 = cv::imread(filenameOutput, IMREAD_UNCHANGED); | ||
ASSERT_EQ(img2.type(), img.type()); | ||
ASSERT_EQ(img2.size(), img.size()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Temporary file will not be removed if test fail on this or previous asserts. We need to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am new to gtest so I don't know that EXPECT should be used. I copied the pattern which was in previous tests: readWrite_32FC1, readWrite_32FC3. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I changed that only in my test readWrite_32FC7, but the same is in several other tests. |
||
EXPECT_LE(cvtest::norm(img, img2, NORM_INF | NORM_RELATIVE), 1e-3); | ||
EXPECT_EQ(0, remove(filenameOutput.c_str())); | ||
} | ||
|
||
|
||
TEST(Imgcodecs_EXR, readWrite_32FC1_half) | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imho using a generated cv::Mat here instead of adding an extra test file to opencv_extra is better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
output
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing file is before testing grayscale and color in current branch. It prints error message as you can't load multispectral image as GRAYSCALE or COLOR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i fixed it on my code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i suggest using this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generates the same file at opencv/opencv_extra#1262
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use the same pattern as tests readWrite_32FC1, readWrite_32FC3, readWrite_32FC1_half, readWrite_32FC3_half. It's generate image file upon GENERATE_DATA define. I don't know when it was called with this define so I do the new test readWrite_32FC7 same way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xaos-cz thank you for your contribution. i am also a common contributor ( a bit more experienced). I think this test is to verify that the change you made is working correctly and to show if a later change breaks your code. It doesn't matter if it's similar in form to the other tests.