这里用到的模块是imageio。用imageio.mimsave
即可将图片序列保存成gif动态图。以下是本人编写的小实验:
import cv2
import imageiopaths = ["./images/0001.png", "./images/0002.png", "./images/0003.png", ...]
frames = []
for ima in paths:img = cv2.imread(ima)frames.append(img)
imageio.mimsave("demo.gif", frames, 'GIF', duration=0.1)
实现效果: