Regular API function

simSetVisionSensorImage / sim.setVisionSensorImage

Description Sets the rgb-image of a vision sensor (and applies any image processing via the vision callback functions). Make sure the vision sensor is flagged as external input. Use sim.getVisionSensorResolution to know the size of the image buffer that you need to provide (buffer size=resolutionX *resolutionY*3). See also sim.setVisionSensorCharImage.
C synopsis simInt simSetVisionSensorImage(simInt sensorHandle,const simFloat* image)
C parameters
sensorHandle: handle of the vision sensor object. Can be combined with sim_handleflag_greyscale (simply add sim_handleflag_greyscale to sensorHandle if you provide grey scale values instead of rgb value) or/and sim_handleflag_rawvalue (simply add sim_handleflag_rawvalue to sensorHandle if you do not wish to trigger image processing).
image: rgb buffer containing the image (buffer size must be resolutionX*resolutionY*3). Values in the buffer should vary between 0 and 1. In case a grey scale image is provided, the buffer size must be resolutionX*resolutionY.
C return value
-1 if operation was not successful. 0 if the image processing didn't trigger anything, 1 if the image processing triggered a detection
Lua synopsis
(1) number result=sim.setVisionSensorImage(number sensorHandle,table image)
(2) number result=sim.setVisionSensorImage(number sensorHandle,string image)
Lua parameters
sensorHandle: handle of the vision sensor object. Can be combined with sim.handleflag_greyscale (simply add sim.handleflag_greyscale to sensorHandle if you provide grey scale values instead of rgb value) or/and sim.handleflag_rawvalue (simply add sim.handleflag_rawvalue to sensorHandle if you do not wish to trigger image processing).
(1) a table containing individual values [0-1] for the red, green and blue components, or for the grey component.
(2) a string containing individual chars [0-255] for the red, green and blue components, or for the grey component.
Lua return values
Same as C-function
Remote API equiv.
B0-based remote API: simxSetVisionSensorImage
Legacy remote API: simxSetVisionSensorImage

All regular API functions on one page