Skip to content

ImageCollection class reads only first frame of animated AVIF files #26297

@sturkmen72

Description

@sturkmen72

System Information

OpenCV version: 4.10.0-dev

Detailed description

ImageCollection::read() method is like below. This implementation is necessary for TIFF files because every frame can be different.

For AVIF animations, calling readHeader() each time causes only the first frame to be read.

Mat ImageCollection::Impl::read() {
    auto result = this->readHeader();
    if(!result) {
        return {};
    }
    return this->readData();
}

Steps to reproduce


#include <opencv2/highgui.hpp>
#include <opencv2/imgcodecs.hpp>

using namespace cv;

int main(int , char** )
{
    std::vector<cv::Mat> imgs;
    imreadmulti("1.avif",imgs);
    for (int i = 0; i < imgs.size(); i++)
    {
        imshow("", imgs[i]);
        waitKey(1);
    }

    ImageCollection collection("1.avif", IMREAD_ANYCOLOR);
    for(auto &&i: collection)
    {
        imshow("", i);
        waitKey(1);
    }

    return 0;
}

Issue submission checklist

  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
  • I updated to the latest OpenCV version and the issue is still there
  • There is reproducer code and related data files (videos, images, onnx, etc)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions