[Matplotlib-users] Matplotlib set_array slow in comparison with cv2
coquelicot
coquelicot at walla.com
Mon Apr 4 16:24:23 EDT 2016
Compare the following 2 codes:
import matplotlib.pyplot as plt
import cv2
def grab_frame(i): #this function simply grab frame i from an image
folder or a video
...
return img_array_like_returned_by_imread_or_cv2.imread
#remove the following two lines to test with opencv:
fr = grab_frame(0)
img = plt.imshow(fr)
for i in range(0,300):
fr = grab_frame(i)
img.set_array(fr)
plt.pause(0.001)
#replace the previous 2 lines by the following 2 lines to
#compare with opencv:
#cv2.imshow('frame', fr)
#if cv2.waitKey(1) & 0xFF == ord('q'): break
My questions are:
1) why is set_array much slower than cv2.imshow ?
2) is it possible to improve this, say by tricking some function of
matplotlib ?
--
View this message in context: http://matplotlib.1069221.n5.nabble.com/Matplotlib-set-array-slow-in-comparison-with-cv2-tp46938.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
More information about the Matplotlib-users
mailing list