mirror of
https://github.com/opencv/opencv.git
synced 2025-08-06 06:26:29 +08:00
Merge pull request #27037 from sturkmen72/ImageCollection_animations
Add a test to ensure ImageCollection class works good with animations
This commit is contained in:
commit
2fbb310265
@ -34,6 +34,11 @@ GifDecoder::~GifDecoder() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool GifDecoder::readHeader() {
|
bool GifDecoder::readHeader() {
|
||||||
|
if (m_frame_count > 1 /* if true, it means readHeader() was called before */)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!m_buf.empty()) {
|
if (!m_buf.empty()) {
|
||||||
if (!m_strm.open(m_buf)) {
|
if (!m_strm.open(m_buf)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -249,6 +249,11 @@ void PngDecoder::readDataFromBuf( void* _png_ptr, unsigned char* dst, size_t si
|
|||||||
|
|
||||||
bool PngDecoder::readHeader()
|
bool PngDecoder::readHeader()
|
||||||
{
|
{
|
||||||
|
if (m_frame_count > 1 /* if true, it means readHeader() was called before */)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Declare dynamic variables before a potential longjmp.
|
// Declare dynamic variables before a potential longjmp.
|
||||||
Chunk chunk;
|
Chunk chunk;
|
||||||
|
|
||||||
|
@ -543,6 +543,51 @@ TEST(Imgcodecs_APNG, imencode_rgba)
|
|||||||
EXPECT_EQ(read_frames.size(), s_animation.frames.size() - 2);
|
EXPECT_EQ(read_frames.size(), s_animation.frames.size() - 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef testing::TestWithParam<string> Imgcodecs_ImageCollection;
|
||||||
|
|
||||||
|
const string exts_multi[] = {
|
||||||
|
#ifdef HAVE_AVIF
|
||||||
|
".avif",
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_IMGCODEC_GIF
|
||||||
|
".gif",
|
||||||
|
#endif
|
||||||
|
".png",
|
||||||
|
#ifdef HAVE_TIFF
|
||||||
|
".tiff",
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_WEBP
|
||||||
|
".webp",
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_P(Imgcodecs_ImageCollection, animations)
|
||||||
|
{
|
||||||
|
Animation s_animation;
|
||||||
|
EXPECT_TRUE(fillFrames(s_animation, false));
|
||||||
|
|
||||||
|
string output = cv::tempfile(GetParam().c_str());
|
||||||
|
ASSERT_TRUE(imwritemulti(output, s_animation.frames));
|
||||||
|
vector<Mat> read_frames;
|
||||||
|
ASSERT_TRUE(imreadmulti(output, read_frames, IMREAD_UNCHANGED));
|
||||||
|
|
||||||
|
{
|
||||||
|
ImageCollection collection(output, IMREAD_UNCHANGED);
|
||||||
|
EXPECT_EQ(read_frames.size(), collection.size());
|
||||||
|
int i = 0;
|
||||||
|
for (auto&& frame : collection)
|
||||||
|
{
|
||||||
|
EXPECT_EQ(0, cvtest::norm(frame, read_frames[i], NORM_INF));
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EXPECT_EQ(0, remove(output.c_str()));
|
||||||
|
}
|
||||||
|
|
||||||
|
INSTANTIATE_TEST_CASE_P(/**/,
|
||||||
|
Imgcodecs_ImageCollection,
|
||||||
|
testing::ValuesIn(exts_multi));
|
||||||
|
|
||||||
#endif // HAVE_PNG
|
#endif // HAVE_PNG
|
||||||
|
|
||||||
}} // namespace
|
}} // namespace
|
||||||
|
Loading…
Reference in New Issue
Block a user