x = []
y = []
fourcc = cv2.VideoWriter_fourcc('M','J','P','G')
out = cv2.VideoWriter("/Users/hyeonseuk/Desktop/ax.avi", fourcc, 30, (1000,200))
def figure_to_array(fig):
fig.canvas.draw()
return np.array(fig.canvas.renderer._renderer)
while len(x_data)>60+cnt:
x = [i for i in range(cnt,cnt+60)]
y = x_data[cnt:cnt+60,0]
cnt+=1
f = plt.figure(figsize=(5,1))
plt.ylim(0,1)
plt.plot(x,y)
plt.close()
f_arr = figure_to_array(f)
f_arr = cv2.resize(f_arr,(1000,200))
out.write(f_arr)
out.release()
cv2.destroyAllWindows()
this code is converting plot_image(f) to array(f_arr) and using this array writing video with opencv. convert plot to array is done. but using convert array with opencv to make video was written but not readable. how i can fix this problem?
Thank you.
