I’ve been trying to capture multiple frames of one of my showbases called binocular_show. However right now I still get the same frame in my array everytime even though I’m trying to run a while loop and render the next frame. Any advice on how I get my pandas simulation frame by frame?
My code is below
class PandasExample():
def init(self):
super().init()
def image(self):
print("hi")
binocular_show.graphicsEngine.renderFrame()
dr = binocular_show.camNode.getDisplayRegion(0)
tex = dr.getScreenshot()
data = tex.getRamImage()
v = memoryview(data).tolist()
img = np.array(v, dtype=np.uint8)
img = img.reshape((tex.getYSize(), tex.getXSize(), 4))
img = img[::-1]
print(img)
if name == ‘main’:
app = QApplication(sys.argv)
panda = PandasExample()
while(True):
panda.image()
sys.exit(app.exec_())
If you wish to capture multiple frames, it would be better to use addRenderTexture on the window with copy-RAM mode instead of getScreenshot to automatically transfer the contents of the texture to CPU RAM after every frame.