#include <iostream>
int main(
int argc,
const char** argv )
{
std::string filename = argc > 1 ? argv[1] : "animated_image.webp";
if (argc == 1)
{
int duration = 200;
for (int i = 0; i < 10; ++i) {
putText(animation_to_save.
frames[i],
format(
"Frame %d", i),
Point(30, 80),
FONT_HERSHEY_SIMPLEX, 1.5,
Scalar(255, 100, 0, 255), 2);
animation_to_save.
durations.push_back(duration);
}
}
if (!success) {
std::cerr << "Failed to load animation frames\n";
return -1;
}
while (true)
for (
size_t i = 0; i < animation.
frames.size(); ++i) {
if (key_code == 27)
exit(0);
}
return 0;
}
Comma-separated Matrix Initializer.
Definition mat.hpp:964
CV_NODISCARD_STD Mat clone() const
Creates a full copy of the array and the underlying data.
Point2i Point
Definition types.hpp:209
Scalar_< double > Scalar
Definition types.hpp:712
#define CV_8UC4
Definition interface.h:80
String format(const char *fmt,...)
Returns a text string formatted using the printf-like expression.
void imshow(const String &winname, InputArray mat)
Displays an image in the specified window.
int waitKey(int delay=0)
Waits for a pressed key.
@ IMWRITE_WEBP_QUALITY
For WEBP, it can be a lossy quality from 1 to 100 (the higher is the better) for IMWRITE_WEBP_LOSSLES...
Definition imgcodecs.hpp:105
bool imwriteanimation(const String &filename, const Animation &animation, const std::vector< int > ¶ms=std::vector< int >())
Saves an Animation to a specified file.
bool imreadanimation(const String &filename, Animation &animation, int start=0, int count=INT16_MAX)
Loads frames from an animated image file into an Animation structure.
void putText(InputOutputArray img, const String &text, Point org, int fontFace, double fontScale, Scalar color, int thickness=1, int lineType=LINE_8, bool bottomLeftOrigin=false)
Draws a text string.
@ FONT_HERSHEY_SIMPLEX
normal size sans-serif font
Definition imgproc.hpp:886
int main(int argc, char *argv[])
Definition highgui_qt.cpp:3
Represents an animation with multiple frames. The Animation struct is designed to store and manage da...
Definition imgcodecs.hpp:295
std::vector< int > durations
Duration for each frame in milliseconds.
Definition imgcodecs.hpp:311
std::vector< Mat > frames
Vector of frames, where each Mat represents a single frame.
Definition imgcodecs.hpp:313