Capture a frame from a Video texture


My objective is simple: I want to capture a frame from a random camera in the scene in the form of a bitmap. So the end result should be a 32x32 (maybe less) matrix with rgb color codes.

The scope of all this is to simulate a color sensor on a robot. I am trying to simulate a NXT lego robot.

Until know with i managed (with the help of the community) to make a video texture with the camera as the source and map it on a plane (code below). Everything works well but know i want to capture that texture in some way.

Any ideas? Thank you very much!

from bge import logic as l
import bge
contr = l.getCurrentController()
obj = contr.owner

if not hasattr(l, 'video'):
	# -- Get the material that is using our texture
	matID = bge.texture.materialID(obj, "IMwebcam.png")
	# -- Create the video texture = bge.texture.Texture(obj, matID)
	scene = l.getCurrentScene()
	objList = scene.objects
	cam1_Name = objList["Camera"] = bge.texture.ImageRender(scene,cam1_Name)
	# -- scale the video = False

	# -- play the video


So…i found a way, it’s really simple (if you know it :stuck_out_tongue: ) = [3,3]
image =

now image is a 3x3 array composed of RGBA elements (255,255,255,255)