1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 07:43:03 +04:00

Merge branch 4.x

This commit is contained in:
Alexander Smorkalov
2026-02-11 13:54:39 +03:00
committed by Alexander Smorkalov
468 changed files with 16647 additions and 11284 deletions
@@ -557,6 +557,7 @@ It also demonstrates how to save multiple images in a TIFF file:
@param filename Name of the file.
@param img (Mat or vector of Mat) Image or Images to be saved.
@param params Format-specific parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ... .) see cv::ImwriteFlags
@return true if the image is successfully written to the specified file; false otherwise.
*/
CV_EXPORTS_W bool imwrite( const String& filename, InputArray img,
const std::vector<int>& params = std::vector<int>());
+16 -2
View File
@@ -211,6 +211,10 @@ bool AvifDecoder::readHeader() {
return true;
decoder_ = avifDecoderCreate();
if (!decoder_) {
CV_Error(Error::StsNoMem, "Failed to create AVIF decoder");
return false;
}
decoder_->strictFlags = AVIF_STRICT_DISABLED;
if (!m_buf.empty()) {
CV_Assert(m_buf.type() == CV_8UC1);
@@ -226,6 +230,11 @@ bool AvifDecoder::readHeader() {
decoder_);
OPENCV_AVIF_CHECK_STATUS(avifDecoderParse(decoder_), decoder_);
if (!decoder_->image) {
CV_Error(Error::StsParseError, "AVIF image is null after parsing");
return false;
}
m_width = decoder_->image->width;
m_height = decoder_->image->height;
m_frame_count = decoder_->imageCount;
@@ -380,7 +389,6 @@ bool AvifEncoder::writeanimation(const Animation& animation,
? AVIF_ADD_IMAGE_FLAG_SINGLE
: AVIF_ADD_IMAGE_FLAG_NONE;
std::vector<AvifImageUniquePtr> images;
std::vector<cv::Mat> imgs_scaled;
for (const cv::Mat &img : animation.frames) {
CV_CheckType(
img.type(),
@@ -388,11 +396,17 @@ bool AvifEncoder::writeanimation(const Animation& animation,
((bit_depth == 10 || bit_depth == 12) && img.depth() == CV_16U),
"AVIF only supports bit depth of 8 with CV_8U input or "
"bit depth of 10 or 12 with CV_16U input");
CV_Check(img.channels(),
img.channels() == 1 || img.channels() == 3 || img.channels() == 4,
"AVIF only supports 1, 3, 4 channels");
images.emplace_back(ConvertToAvif(img, do_lossless, bit_depth, m_metadata));
auto avifImg = ConvertToAvif(img, do_lossless, bit_depth, m_metadata);
if (!avifImg) {
CV_Error(Error::StsError, "Failed to convert Mat to AVIF image");
return false;
}
images.emplace_back(std::move(avifImg));
}
for (size_t i = 0; i < images.size(); i++)
-3
View File
@@ -130,9 +130,6 @@ bool ExrDecoder::readHeader()
m_file = new InputFile( m_filename.c_str() );
if( !m_file ) // probably paranoid
return false;
m_datawindow = m_file->header().dataWindow();
m_width = m_datawindow.max.x - m_datawindow.min.x + 1;
m_height = m_datawindow.max.y - m_datawindow.min.y + 1;
+4 -3
View File
@@ -42,6 +42,7 @@
#include "precomp.hpp"
#include <cstdint>
#include <memory>
#ifdef HAVE_PNG
@@ -364,7 +365,7 @@ bool PngDecoder::readHeader()
m_color_type = color_type;
m_bit_depth = bit_depth;
if (m_is_fcTL_loaded && ((long long int)x0 + w0 > m_width || (long long int)y0 + h0 > m_height || dop > 2 || bop > 1))
if (m_is_fcTL_loaded && ((int64_t)x0 + w0 > m_width || (int64_t)y0 + h0 > m_height || dop > 2 || bop > 1))
return false;
png_color_16p background_color;
@@ -456,7 +457,7 @@ bool PngDecoder::readData( Mat& img )
if (dop == 2)
memcpy(frameNext.getPixels(), frameCur.getPixels(), imagesize);
if (x0 + w0 > frameCur.getWidth() || y0 + h0 > frameCur.getHeight())
if ((uint64_t)x0 + w0 > frameCur.getWidth() || (uint64_t)y0 + h0 > frameCur.getHeight())
return false;
compose_frame(frameCur.getRows(), frameRaw.getRows(), bop, x0, y0, w0, h0, mat_cur);
@@ -508,7 +509,7 @@ bool PngDecoder::readData( Mat& img )
dop = chunk.p[32];
bop = chunk.p[33];
if (int(x0 + w0) > img.cols || int(y0 + h0) > img.rows || dop > 2 || bop > 1)
if ((int64_t)x0 + w0 > img.cols || (int64_t)y0 + h0 > img.rows || dop > 2 || bop > 1)
{
return false;
}
+1 -1
View File
@@ -995,7 +995,7 @@ bool TiffDecoder::readData( Mat& img )
break;
default:
CV_LOG_ONCE_ERROR(NULL, "OpenCV TIFF(line " << __LINE__ << "): Unsupported convertion :"
CV_LOG_ONCE_ERROR(NULL, "OpenCV TIFF(line " << __LINE__ << "): Unsupported conversion :"
<< " bpp = " << bpp << " ncn = " << (int)ncn
<< " wanted_channels =" << wanted_channels );
break;
+1 -1
View File
@@ -213,7 +213,7 @@ TEST(Imgcodecs_EXR, read_YA_unchanged)
ASSERT_FALSE(img.empty());
ASSERT_EQ(CV_32FC2, img.type());
// Cannot test writing, 2 channel writing not suppported by loadsave
// Cannot test writing, 2 channel writing not supported by loadsave
}
TEST(Imgcodecs_EXR, read_YC_changeDepth)