Regular API function

simGetVisionSensorImage / sim.getVisionSensorImage

Description Retrieves the rgb-image (or a portion of it) of a vision sensor. Use sim.getVisionSensorResolution to know the resolution of the full image. The returned data doesn't make sense if sim.handleVisionSensor wasn't called previously (sim.handleVisionSensor is called by default in the main script if the vision sensor is not tagged as explicit handling). See also sim.getVisionSensorCharImage and sim.setVisionSensorImage.
C/C++
synopsis
simFloat* simGetVisionSensorImage(simInt sensorHandle)
C/C++
parameters
sensorHandle: handle of the vision sensor. Can be combined with sim_handleflag_greyscale (simply add sim_handleflag_greyscale to sensorHandle), if you wish to retrieve the grey scale equivalent.
C/C++
return value
image buffer (buffer size is resolutionX*resolutionY*3 or resolutionX*resolutionY in case of a grey scale image retrieval) or nullptr in case of an error. The user is in charge of releasing the returned buffer with simReleaseBuffer. Returned values are in the range of 0-1 (0=min. intensity, 1=max. intensity)
Lua synopsis table/string imageBuffer=sim.getVisionSensorImage(int sensorHandle,int posX=0,int posY=0,int sizeX=0,int sizeY=0,int returnType=0)
Lua parameters
sensorHandle: handle of the vision sensor. Can be combined with sim.handleflag_greyscale (simply add sim.handleflag_greyscale to sensorHandle), if you wish to retrieve the grey scale equivalent.
posX / posY: position of the image portion to retrieve. Zero by default.
sizeX / sizeY: size of the image portion to retrieve. Zero by default, which means that the full image should be retrieved
returnType: the type of the returned buffer. 0 returns a table filled with rgb values in the range 0-1, 1 returns a string filled with rgb values in the range 0-255
Lua return values
imageBuffer: a table containing rgb values (table[] size is sizeX*sizeY*3, rgb values in the range 0-1) or a string containing rgb values (table[] size is sizeX*sizeY*3, rgb values in the range 0-255). In case of a grey scale image retrieval, the image buffer will contain grey values or grey-alpha values.
Python synopsis list/bytes imageBuffer=sim.getVisionSensorImage(int sensorHandle,int posX=0,int posY=0,int sizeX=0,int sizeY=0,int returnType=0)