I am attempting to use the cv2 module to create a live scatter plot for each frame of a video. The code below does exactly that.
However with more than 8 minute of footage containing more than 60000 frames to process, the code is not efficient and does take much longer than necessary to get the desired output.
vidcap = cv2.VideoCapture(filepath)
fig, ax = plt.subplots(1)
plt.ion()
x=df["time"][7:100]
y=df["force"][7:100]
for i in range(len(x)):
vidcap.set(1,590)
ret, image = vidcap.read()
frameId = vidcap.get(1)
plt.imshow(image,extent=[0,200,0,100], aspect='auto')
plt.subplot(221)
plt.plot(x[0+i:1+i],y[0+i:1+i],'or', lw=2)
plt.subplot(222)
fig.set_size_inches(20, 10)
plt.pause(.000001)
plt.draw()
I have considered using pyqtgraph to increase the speed of the process. Is there a better way to process and plot on a frame of a video?