0
$\begingroup$

I am currently building a simulator using the Blender Game Engine. I got stuck at the point where I need to extract the camera image from the virtual camera.

I've found the VideoTexture.ImageRender class but this class does not provide any image.

The code I am using is the following:

import GameLogic
import VideoTexture

scene = GameLogic.getCurrentScene()
cam = scene.active_camera

imageRender = VideoTexture.ImageRender(scene, cam)

imageRender.refresh()

if(imageRender.valid):
    print(imageRender.image)
else:
    print("No image available")

The output imageRender.image is always None. Am I missing something? Anyone knows where the problem might be?

Thank you very much for your help.

enter image description here

$\endgroup$
1
$\begingroup$

Okay. I looked into the source code of Blender and it seems that ImageRender only works when rendering to a texture and it is not the currently active camera.

What I did was to add an additional plane, create a material along with a texture rendered it to that plane. After that, I was able to store the image.

In addition to that, I set the new camera as the active camera for the scene. Hope that this answer will help other people.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.