Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
417ac944
Commit
417ac944
authored
Jun 08, 2019
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #14767 from alalek:imgcodecs_test_exr
parents
6d916c5b
02bfd207
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
121 additions
and
0 deletions
+121
-0
test_exr.impl.hpp
modules/imgcodecs/test/test_exr.impl.hpp
+117
-0
test_grfmt.cpp
modules/imgcodecs/test/test_grfmt.cpp
+4
-0
No files found.
modules/imgcodecs/test/test_exr.impl.hpp
0 → 100644
View file @
417ac944
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html
//#define GENERATE_DATA
namespace
opencv_test
{
namespace
{
TEST
(
Imgcodecs_EXR
,
readWrite_32FC1
)
{
const
string
root
=
cvtest
::
TS
::
ptr
()
->
get_data_path
();
const
string
filenameInput
=
root
+
"readwrite/test32FC1.exr"
;
const
string
filenameOutput
=
cv
::
tempfile
(
".exr"
);
#ifndef GENERATE_DATA
const
Mat
img
=
cv
::
imread
(
filenameInput
,
IMREAD_UNCHANGED
);
#else
const
Size
sz
(
64
,
32
);
Mat
img
(
sz
,
CV_32FC1
,
Scalar
(
0.5
,
0.1
,
1
));
img
(
Rect
(
10
,
5
,
sz
.
width
-
30
,
sz
.
height
-
20
)).
setTo
(
Scalar
(
1
,
0
,
0
));
ASSERT_TRUE
(
cv
::
imwrite
(
filenameInput
,
img
));
#endif
ASSERT_FALSE
(
img
.
empty
());
ASSERT_EQ
(
CV_32FC1
,
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
());
EXPECT_LE
(
cvtest
::
norm
(
img
,
img2
,
NORM_INF
|
NORM_RELATIVE
),
1e-3
);
EXPECT_EQ
(
0
,
remove
(
filenameOutput
.
c_str
()));
}
TEST
(
Imgcodecs_EXR
,
readWrite_32FC3
)
{
const
string
root
=
cvtest
::
TS
::
ptr
()
->
get_data_path
();
const
string
filenameInput
=
root
+
"readwrite/test32FC3.exr"
;
const
string
filenameOutput
=
cv
::
tempfile
(
".exr"
);
#ifndef GENERATE_DATA
const
Mat
img
=
cv
::
imread
(
filenameInput
,
IMREAD_UNCHANGED
);
#else
const
Size
sz
(
64
,
32
);
Mat
img
(
sz
,
CV_32FC3
,
Scalar
(
0.5
,
0.1
,
1
));
img
(
Rect
(
10
,
5
,
sz
.
width
-
30
,
sz
.
height
-
20
)).
setTo
(
Scalar
(
1
,
0
,
0
));
ASSERT_TRUE
(
cv
::
imwrite
(
filenameInput
,
img
));
#endif
ASSERT_FALSE
(
img
.
empty
());
ASSERT_EQ
(
CV_32FC3
,
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
());
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
)
{
const
string
root
=
cvtest
::
TS
::
ptr
()
->
get_data_path
();
const
string
filenameInput
=
root
+
"readwrite/test32FC1_half.exr"
;
const
string
filenameOutput
=
cv
::
tempfile
(
".exr"
);
std
::
vector
<
int
>
params
;
params
.
push_back
(
IMWRITE_EXR_TYPE
);
params
.
push_back
(
IMWRITE_EXR_TYPE_HALF
);
#ifndef GENERATE_DATA
const
Mat
img
=
cv
::
imread
(
filenameInput
,
IMREAD_UNCHANGED
);
#else
const
Size
sz
(
64
,
32
);
Mat
img
(
sz
,
CV_32FC1
,
Scalar
(
0.5
,
0.1
,
1
));
img
(
Rect
(
10
,
5
,
sz
.
width
-
30
,
sz
.
height
-
20
)).
setTo
(
Scalar
(
1
,
0
,
0
));
ASSERT_TRUE
(
cv
::
imwrite
(
filenameInput
,
img
,
params
));
#endif
ASSERT_FALSE
(
img
.
empty
());
ASSERT_EQ
(
CV_32FC1
,
img
.
type
());
ASSERT_TRUE
(
cv
::
imwrite
(
filenameOutput
,
img
,
params
));
const
Mat
img2
=
cv
::
imread
(
filenameOutput
,
IMREAD_UNCHANGED
);
ASSERT_EQ
(
img2
.
type
(),
img
.
type
());
ASSERT_EQ
(
img2
.
size
(),
img
.
size
());
EXPECT_LE
(
cvtest
::
norm
(
img
,
img2
,
NORM_INF
|
NORM_RELATIVE
),
1e-3
);
EXPECT_EQ
(
0
,
remove
(
filenameOutput
.
c_str
()));
}
TEST
(
Imgcodecs_EXR
,
readWrite_32FC3_half
)
{
const
string
root
=
cvtest
::
TS
::
ptr
()
->
get_data_path
();
const
string
filenameInput
=
root
+
"readwrite/test32FC3_half.exr"
;
const
string
filenameOutput
=
cv
::
tempfile
(
".exr"
);
std
::
vector
<
int
>
params
;
params
.
push_back
(
IMWRITE_EXR_TYPE
);
params
.
push_back
(
IMWRITE_EXR_TYPE_HALF
);
#ifndef GENERATE_DATA
const
Mat
img
=
cv
::
imread
(
filenameInput
,
IMREAD_UNCHANGED
);
#else
const
Size
sz
(
64
,
32
);
Mat
img
(
sz
,
CV_32FC3
,
Scalar
(
0.5
,
0.1
,
1
));
img
(
Rect
(
10
,
5
,
sz
.
width
-
30
,
sz
.
height
-
20
)).
setTo
(
Scalar
(
1
,
0
,
0
));
ASSERT_TRUE
(
cv
::
imwrite
(
filenameInput
,
img
,
params
));
#endif
ASSERT_FALSE
(
img
.
empty
());
ASSERT_EQ
(
CV_32FC3
,
img
.
type
());
ASSERT_TRUE
(
cv
::
imwrite
(
filenameOutput
,
img
,
params
));
const
Mat
img2
=
cv
::
imread
(
filenameOutput
,
IMREAD_UNCHANGED
);
ASSERT_EQ
(
img2
.
type
(),
img
.
type
());
ASSERT_EQ
(
img2
.
size
(),
img
.
size
());
EXPECT_LE
(
cvtest
::
norm
(
img
,
img2
,
NORM_INF
|
NORM_RELATIVE
),
1e-3
);
EXPECT_EQ
(
0
,
remove
(
filenameOutput
.
c_str
()));
}
}}
// namespace
modules/imgcodecs/test/test_grfmt.cpp
View file @
417ac944
...
...
@@ -352,3 +352,7 @@ TEST(Imgcodecs, write_parameter_type)
}
}}
// namespace
#ifdef HAVE_OPENEXR
#include "test_exr.impl.hpp"
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment