1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 23:33:05 +04:00

add getFrameCount()

This commit is contained in:
Suleyman TURKMEN
2024-07-03 19:55:35 +03:00
parent 53f51275e4
commit cdd8395f68
7 changed files with 11 additions and 21 deletions
+1
View File
@@ -195,6 +195,7 @@ bool AvifDecoder::readHeader() {
m_width = decoder_->image->width;
m_height = decoder_->image->height;
m_frame_count = decoder_->imageCount;
channels_ = (decoder_->image->yuvFormat == AVIF_PIXEL_FORMAT_YUV400) ? 1 : 3;
if (decoder_->alphaPresent) ++channels_;
bit_depth_ = decoder_->image->depth;
+1
View File
@@ -54,6 +54,7 @@ BaseImageDecoder::BaseImageDecoder()
m_buf_supported = false;
m_scale_denom = 1;
m_use_rgb = false;
m_frame_count = 1;
}
+2
View File
@@ -64,6 +64,7 @@ public:
int width() const { return m_width; }
int height() const { return m_height; }
size_t getFrameCount() const { return m_frame_count; }
virtual int type() const { return m_type; }
ExifEntry_t getExifTag(const ExifTagName tag) const;
@@ -93,6 +94,7 @@ protected:
bool m_buf_supported;
bool m_use_rgb; // flag of decode image as RGB order instead of BGR.
ExifReader m_exif;
size_t m_frame_count;
};
+1
View File
@@ -279,6 +279,7 @@ bool TiffDecoder::readHeader()
m_width = wdth;
m_height = hght;
m_frame_count = TIFFNumberOfDirectories(tif);
if (ncn == 3 && photometric == PHOTOMETRIC_LOGLUV)
{
m_type = CV_32FC3;
+1 -19
View File
@@ -1263,26 +1263,8 @@ void ImageCollection::Impl::init(String const& filename, int flags) {
m_decoder->setSource(filename);
CV_Assert(m_decoder->readHeader());
// count the pages of the image collection
size_t count = 1;
while(m_decoder->nextPage()) count++;
m_size = count;
m_size = m_decoder->getFrameCount();
m_pages.resize(m_size);
// Reinitialize the decoder because we advanced to the last page while counting the pages of the image
#ifdef HAVE_GDAL
if (m_flags != IMREAD_UNCHANGED && (m_flags & IMREAD_LOAD_GDAL) == IMREAD_LOAD_GDAL) {
m_decoder = GdalDecoder().newDecoder();
}
else {
#endif
m_decoder = findDecoder(m_filename);
#ifdef HAVE_GDAL
}
#endif
m_decoder->setSource(m_filename);
m_decoder->readHeader();
}
size_t ImageCollection::Impl::size() const { return m_size; }