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
47396480
Commit
47396480
authored
Dec 29, 2014
by
Ashod Nakashian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added imread and imreadmulti regression tests.
parent
61ca3810
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
103 additions
and
1 deletion
+103
-1
grfmt_tiff.cpp
modules/imgcodecs/src/grfmt_tiff.cpp
+1
-1
test_grfmt.cpp
modules/imgcodecs/test/test_grfmt.cpp
+102
-0
No files found.
modules/imgcodecs/src/grfmt_tiff.cpp
View file @
47396480
...
...
@@ -189,7 +189,7 @@ bool TiffDecoder::nextPage()
{
// Prepare the next page, if any.
return
m_tif
&&
TIFFReadDirectory
(
static_cast
<
TIFF
*>
(
m_tif
))
&&
TIFFReadDirectory
(
static_cast
<
TIFF
*>
(
m_tif
))
&&
readHeader
();
}
...
...
modules/imgcodecs/test/test_grfmt.cpp
View file @
47396480
...
...
@@ -45,6 +45,68 @@
using
namespace
cv
;
using
namespace
std
;
static
bool
mats_equal
(
const
Mat
&
lhs
,
const
Mat
&
rhs
)
{
if
(
lhs
.
channels
()
!=
rhs
.
channels
()
||
lhs
.
depth
()
!=
rhs
.
depth
()
||
lhs
.
size
().
height
!=
rhs
.
size
().
height
||
lhs
.
size
().
width
!=
rhs
.
size
().
width
)
{
return
false
;
}
Mat
diff
=
(
lhs
!=
rhs
);
const
Scalar
s
=
sum
(
diff
);
for
(
int
i
=
0
;
i
<
s
.
channels
;
++
i
)
{
if
(
s
[
i
]
!=
0
)
{
return
false
;
}
}
return
true
;
}
static
bool
imread_compare
(
const
string
&
filepath
,
int
flags
=
IMREAD_COLOR
)
{
vector
<
Mat
>
pages
;
if
(
!
imreadmulti
(
filepath
,
pages
,
flags
)
||
pages
.
empty
())
{
return
false
;
}
const
Mat
single
=
imread
(
filepath
,
flags
);
return
mats_equal
(
single
,
pages
[
0
]);
}
TEST
(
Imgcodecs_imread
,
regression
)
{
const
char
*
const
filenames
[]
=
{
"color_palette_alpha.png"
,
"multipage.tif"
,
"rle.hdr"
,
"ordinary.bmp"
,
"rle8.bmp"
,
"test_1_c1.jpg"
};
const
string
folder
=
string
(
cvtest
::
TS
::
ptr
()
->
get_data_path
())
+
"/readwrite/"
;
for
(
size_t
i
=
0
;
i
<
sizeof
(
filenames
)
/
sizeof
(
filenames
[
0
]);
++
i
)
{
ASSERT_TRUE
(
imread_compare
(
folder
+
string
(
filenames
[
i
]),
IMREAD_UNCHANGED
));
ASSERT_TRUE
(
imread_compare
(
folder
+
string
(
filenames
[
i
]),
IMREAD_GRAYSCALE
));
ASSERT_TRUE
(
imread_compare
(
folder
+
string
(
filenames
[
i
]),
IMREAD_COLOR
));
ASSERT_TRUE
(
imread_compare
(
folder
+
string
(
filenames
[
i
]),
IMREAD_ANYDEPTH
));
ASSERT_TRUE
(
imread_compare
(
folder
+
string
(
filenames
[
i
]),
IMREAD_ANYCOLOR
));
ASSERT_TRUE
(
imread_compare
(
folder
+
string
(
filenames
[
i
]),
IMREAD_LOAD_GDAL
));
}
}
class
CV_GrfmtWriteBigImageTest
:
public
cvtest
::
BaseTest
{
...
...
@@ -591,6 +653,46 @@ TEST(Imgcodecs_Tiff, decode_tile_remainder)
CV_GrfmtReadTifTiledWithNotFullTiles
test
;
test
.
safe_run
();
}
class
CV_GrfmtReadTifMultiPage
:
public
cvtest
::
BaseTest
{
private
:
void
compare
(
int
flags
)
{
const
string
folder
=
string
(
cvtest
::
TS
::
ptr
()
->
get_data_path
())
+
"/readwrite/"
;
const
int
page_count
=
6
;
vector
<
Mat
>
pages
;
bool
res
=
imreadmulti
(
folder
+
"multipage.tif"
,
pages
,
flags
);
ASSERT_TRUE
(
res
==
true
);
ASSERT_TRUE
(
pages
.
size
()
==
page_count
);
for
(
int
i
=
0
;
i
<
page_count
;
i
++
)
{
char
buffer
[
256
];
sprintf
(
buffer
,
"%smultipage_p%d.tif"
,
folder
.
c_str
(),
i
+
1
);
const
string
filepath
(
buffer
);
const
Mat
page
=
imread
(
filepath
,
flags
);
ASSERT_TRUE
(
mats_equal
(
page
,
pages
[
i
]));
}
}
public
:
void
run
(
int
)
{
compare
(
IMREAD_UNCHANGED
);
compare
(
IMREAD_GRAYSCALE
);
compare
(
IMREAD_COLOR
);
compare
(
IMREAD_ANYDEPTH
);
compare
(
IMREAD_ANYCOLOR
);
compare
(
IMREAD_LOAD_GDAL
);
}
};
TEST
(
Imgcodecs_Tiff
,
decode_multipage
)
{
CV_GrfmtReadTifMultiPage
test
;
test
.
safe_run
();
}
#endif
#ifdef HAVE_WEBP
...
...
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