use numpy to reshape image data to matplotlib compatible format
fixes issue #1871
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
import pybullet
|
import pybullet
|
||||||
import time
|
import time
|
||||||
|
import numpy as np #to reshape for matplotlib
|
||||||
|
|
||||||
plt.ion()
|
plt.ion()
|
||||||
|
|
||||||
@@ -59,7 +60,13 @@ while(1):
|
|||||||
#note that sending the data using imshow to matplotlib is really slow, so we use set_data
|
#note that sending the data using imshow to matplotlib is really slow, so we use set_data
|
||||||
|
|
||||||
#plt.imshow(rgb,interpolation='none')
|
#plt.imshow(rgb,interpolation='none')
|
||||||
image.set_data(rgb)
|
|
||||||
|
|
||||||
|
#reshape is needed
|
||||||
|
np_img_arr = np.reshape(rgb, (h, w, 4))
|
||||||
|
np_img_arr = np_img_arr*(1./255.)
|
||||||
|
|
||||||
|
image.set_data(np_img_arr)
|
||||||
ax.plot([0])
|
ax.plot([0])
|
||||||
#plt.draw()
|
#plt.draw()
|
||||||
#plt.show()
|
#plt.show()
|
||||||
|
|||||||
@@ -60,15 +60,15 @@ while (1):
|
|||||||
|
|
||||||
#note that sending the data to matplotlib is really slow
|
#note that sending the data to matplotlib is really slow
|
||||||
|
|
||||||
#reshape is not needed
|
#reshape is needed
|
||||||
#np_img_arr = np.reshape(rgb, (h, w, 4))
|
np_img_arr = np.reshape(rgb, (h, w, 4))
|
||||||
#np_img_arr = np_img_arr*(1./255.)
|
np_img_arr = np_img_arr*(1./255.)
|
||||||
|
|
||||||
#show
|
#show
|
||||||
#plt.imshow(np_img_arr,interpolation='none',extent=(0,1600,0,1200))
|
#plt.imshow(np_img_arr,interpolation='none',extent=(0,1600,0,1200))
|
||||||
#image = plt.imshow(np_img_arr,interpolation='none',animated=True,label="blah")
|
#image = plt.imshow(np_img_arr,interpolation='none',animated=True,label="blah")
|
||||||
|
|
||||||
image.set_data(rgb)#np_img_arr)
|
image.set_data(np_img_arr)
|
||||||
ax.plot([0])
|
ax.plot([0])
|
||||||
#plt.draw()
|
#plt.draw()
|
||||||
#plt.show()
|
#plt.show()
|
||||||
|
|||||||
Reference in New Issue
Block a user