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

Merge branch 4.x

This commit is contained in:
Alexander Smorkalov
2025-07-17 18:23:51 +03:00
140 changed files with 2891 additions and 1208 deletions
@@ -251,6 +251,15 @@ enum ImwriteGIFCompressionFlags {
IMWRITE_GIF_COLORTABLE_SIZE_256 = 8
};
enum ImageMetadataType
{
IMAGE_METADATA_UNKNOWN = -1,
IMAGE_METADATA_EXIF = 0,
IMAGE_METADATA_XMP = 1,
IMAGE_METADATA_ICCP = 2,
IMAGE_METADATA_MAX = 2
};
//! @} imgcodecs_flags
/** @brief Represents an animation with multiple frames.
@@ -277,6 +286,8 @@ struct CV_EXPORTS_W_SIMPLE Animation
CV_PROP_RW std::vector<int> durations;
//! Vector of frames, where each Mat represents a single frame.
CV_PROP_RW std::vector<Mat> frames;
//! image that can be used for the format in addition to the animation or if animation is not supported in the reader (like in PNG).
CV_PROP_RW Mat still_image;
/** @brief Constructs an Animation object with optional loop count and background color.
@@ -358,6 +369,17 @@ The image passing through the img parameter can be pre-allocated. The memory is
*/
CV_EXPORTS_W void imread( const String& filename, OutputArray dst, int flags = IMREAD_COLOR_BGR );
/** @brief Reads an image from a file together with associated metadata.
The function imreadWithMetadata reads image from the specified file. It does the same thing as imread, but additionally reads metadata if the corresponding file contains any.
@param filename Name of the file to be loaded.
@param metadataTypes Output vector with types of metadata chucks returned in metadata, see ImageMetadataType.
@param metadata Output vector of vectors or vector of matrices to store the retrieved metadata
@param flags Flag that can take values of cv::ImreadModes
*/
CV_EXPORTS_W Mat imreadWithMetadata( const String& filename, CV_OUT std::vector<int>& metadataTypes,
OutputArrayOfArrays metadata, int flags = IMREAD_ANYCOLOR);
/** @brief Loads a multi-page image from a file.
The function imreadmulti loads a multi-page image from the specified file into a vector of Mat objects.
@@ -462,7 +484,7 @@ filename extension (see cv::imread for the list of extensions). In general, only
single-channel or 3-channel (with 'BGR' channel order) images
can be saved using this function, with these exceptions:
- With OpenEXR encoder, only 32-bit float (CV_32F) images can be saved.
- With OpenEXR encoder, only 32-bit float (CV_32F) images can be saved. More than 4 channels can be saved. (imread can load it then.)
- 8-bit unsigned (CV_8U) images are not supported.
- With Radiance HDR encoder, non 64-bit float (CV_64F) images can be saved.
- All images will be converted to 32-bit float (CV_32F).
@@ -507,6 +529,20 @@ It also demonstrates how to save multiple images in a TIFF file:
CV_EXPORTS_W bool imwrite( const String& filename, InputArray img,
const std::vector<int>& params = std::vector<int>());
/** @brief Saves an image to a specified file with metadata
The function imwriteWithMetadata saves the image to the specified file. It does the same thing as imwrite, but additionally writes metadata if the corresponding format supports it.
@param filename Name of the file. As with imwrite, image format is determined by the file extension.
@param img (Mat or vector of Mat) Image or Images to be saved.
@param metadataTypes Vector with types of metadata chucks stored in metadata to write, see ImageMetadataType.
@param metadata Vector of vectors or vector of matrices with chunks of metadata to store into the file
@param params Format-specific parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ... .) see cv::ImwriteFlags
*/
CV_EXPORTS_W bool imwriteWithMetadata( const String& filename, InputArray img,
const std::vector<int>& metadataTypes,
InputArrayOfArrays& metadata,
const std::vector<int>& params = std::vector<int>());
//! @brief multi-image overload for bindings
CV_WRAP static inline
bool imwritemulti(const String& filename, InputArrayOfArrays img,
@@ -528,6 +564,22 @@ See cv::imread for the list of supported formats and flags description.
*/
CV_EXPORTS_W Mat imdecode( InputArray buf, int flags );
/** @brief Reads an image from a buffer in memory together with associated metadata.
The function imdecode reads an image from the specified buffer in the memory. If the buffer is too short or
contains invalid data, the function returns an empty matrix ( Mat::data==NULL ).
See cv::imread for the list of supported formats and flags description.
@note In the case of color images, the decoded images will have the channels stored in **B G R** order.
@param buf Input array or vector of bytes.
@param metadataTypes Output vector with types of metadata chucks returned in metadata, see ImageMetadataType.
@param metadata Output vector of vectors or vector of matrices to store the retrieved metadata
@param flags The same flags as in cv::imread, see cv::ImreadModes.
*/
CV_EXPORTS_W Mat imdecodeWithMetadata( InputArray buf, CV_OUT std::vector<int>& metadataTypes,
OutputArrayOfArrays metadata, int flags = IMREAD_ANYCOLOR );
/** @overload
@param buf Input array or vector of bytes.
@param flags The same flags as in cv::imread, see cv::ImreadModes.
@@ -566,6 +618,24 @@ CV_EXPORTS_W bool imencode( const String& ext, InputArray img,
CV_OUT std::vector<uchar>& buf,
const std::vector<int>& params = std::vector<int>());
/** @brief Encodes an image into a memory buffer.
The function imencode compresses the image and stores it in the memory buffer that is resized to fit the
result. See cv::imwrite for the list of supported formats and flags description.
@param ext File extension that defines the output format. Must include a leading period.
@param img Image to be compressed.
@param metadataTypes Vector with types of metadata chucks stored in metadata to write, see ImageMetadataType.
@param metadata Vector of vectors or vector of matrices with chunks of metadata to store into the file
@param buf Output buffer resized to fit the compressed image.
@param params Format-specific parameters. See cv::imwrite and cv::ImwriteFlags.
*/
CV_EXPORTS_W bool imencodeWithMetadata( const String& ext, InputArray img,
const std::vector<int>& metadataTypes,
InputArrayOfArrays metadata,
CV_OUT std::vector<uchar>& buf,
const std::vector<int>& params = std::vector<int>());
/** @brief Encodes array of images into a memory buffer.
The function is analog to cv::imencode for in-memory multi-page image compression.
@@ -589,7 +659,7 @@ This can be useful for verifying support for a given image format before attempt
@return true if an image reader for the specified file is available and the file can be opened, false otherwise.
@note The function checks the availability of image codecs that are either built into OpenCV or dynamically loaded.
It does not check for the actual existence of the file but rather the ability to read the specified file type.
It does not load the image codec implementation and decode data, but uses signature check.
If the file cannot be opened or the format is unsupported, the function will return false.
@sa cv::haveImageWriter, cv::imread, cv::imdecode