这是太长的评论。所以张贴作为答案。在
我直接用图书馆读一个视频文件。它正在按要求工作。颜色BGR2RGB正在按要求工作,帧正在更改并播放到最后一帧。在import cv2
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
import skvideo.io
index =0
inF=skvideo.io.vread('test.avi')
#inF=[]
#for frames in clip.iter_frames():
# inF.append(frames)
global inF
def grab_frame():
print(index)
frame = inF[index]
return cv2.cvtColor(frame,cv2.COLOR_BGR2RGB)
#Initiate the two cameras
cap1 = clip
#create two subplots
ax1 = plt.subplot(1,2,1)
#create two image plots
im1 = ax1.imshow(grab_frame())
def update(i):
global index
im1.set_data(grab_frame())
index+=1
ani = FuncAnimation(plt.gcf(), update, interval=10)
plt.show()
以上代码没有问题。错误的来源是你的视频或者你阅读视频的方式。很明显,它会打印0到32帧测试.avi). 在