I know that I can display a .png file, So I was thought that i can display a .gif file. I am using opencv and i will send the code for the displaying of the .png file (that is working when you change the directory to a valid one).
#include <stdio.h>
#include <opencv2\highgui\highgui_c.h>
int main(void)
{
int i;
cvNamedWindow("Display window", CV_WINDOW_AUTOSIZE); //create a window
//create an image
IplImage* image = cvLoadImage("C:\\c1.png", 1); //change to a valid directory
if (!image)//The image is empty.
{
printf("could not open image\n");
}
else
{
cvShowImage("Display window", image);
cvWaitKey(0);
system("pause");
cvReleaseImage(&image);
}
return 0;
}
unfortunately there is no direct gif support in opencv.
cv2.imread(image.gif)
is not possible.But there are many other alternatives to insert a GIF
You can use moviepy module to make it happen
Here is an example: Converting a video excerpt into a GIF
importing moviepy module
from moviepy.editor import *
Then a video file is opened and selected the part between 1'22.65 (1 minute 22.65 seconds) and 1'23.2, reduce its size (to 30% of the original) and save it as a GIF
clip = (VideoFileClip("frozen_trailer.mp4").subclip((1,22.65),(1,23.2)).resize(0.3))
clip.write_gif("use_your_head.gif")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.