我有一组 .png 文件,我正在尝试为它们制作基于时间顺序的动画,但是我收到以下错误:
TypeError: Object does not appear to be a 8-bit string path or a Python file-like object
代码:
import matplotlib.pyplot as plt
import matplotlib.image as mgimg
from matplotlib import animation
import cv2
import os
dir_path='/Users/neginhayatbini/Documents/GOESR/Result'
images = []
for f in os.listdir(dir_path):
if f.endswith('.png'):
images.append(f)
fig = plt.figure()
myimages = []
for i in range (len(images)):
img = mgimg.imread(images)
imgplot = plt.imshow(img)
myimages.append([imgplot])
my_anim = animation.ArtistAnimation(fig, myimages, interval=1000,
blit=True, repeat_delay=1000)
my_anim.save("animation.mp4")
plt.show()