1

I have a small animation (pyglet) that I am taking a screenshot of that I want to use in a CNN afterwards. At the moment, I have to save a screenshot (ColorBufferImage) and then upload it again directly so that the image is in the correct format for the CNN (PIL format). For better performance I would skip the whole thing without having to save the image extra. Here is my code:

pyglet.image.get_buffer_manager().get_color_buffer().save('screenshot.png')
image = tensorflow.keras.utils.load_img('screenshot.png',color_mode='rgb',target_size=(256, 256),interpolation='nearest',keep_aspect_ratio=False)
jsmndr
  • 11
  • 1
  • I don't use either of your packages, but imagine you could write to an *"in-memory"* `BytesIO` and pass that (or its contens) to tensorflow like this https://stackoverflow.com/a/73819899/2836621 – Mark Setchell Oct 05 '22 at 16:41

0 Answers0