Regular API function
simHandleVisionSensor / sim.handleVisionSensor
Description
|
Handles (performs sensing, etc. of) a vision sensor object. It will (1) clear previous computed image processing data, (2) read an image and (3) perform image processing via the vision callback functions (if the vision sensor is using an external input only (1) will be performed). See also sim.readVisionSensor, sim.checkVisionSensor, sim.checkVisionSensorEx and sim.resetVisionSensor.
|
C/C++ synopsis
|
simInt simHandleVisionSensor(simInt visionSensorHandle,simFloat** auxValues,simInt** auxValuesCount)
|
C/C++ parameters |
visionSensorHandle: handle of a vision sensor object or sim.handle_all or sim.handle_all_except_explicit. (sim.handle_all will handle all vision sensor objects, while sim.handle_all_except_explicit will only handle those that are not marked as "explicit handling")
auxValues: by default CoppeliaSim returns one packet of 15 auxiliary values:the minimum of {intensity, red, green, blue, depth value}, the maximum of {intensity, red, green, blue, depth value}, and the average of {intensity, red, green, blue, depth value}. If the vision callback function returns additional values, then they will be appended as packets to the first packet. AuxValues can be nullptr. The user is in charge of releasing the auxValues buffer with simReleaseBuffer(*auxValues). If visionSensorHandle is sim.handle_all or sim.handle_all_except_explicit, nothing is returned in auxValues.
auxValuesCount: contains information about the number of auxiliary value packets and packet sizes returned in auxValues. The first value is the number of packets, the second is the size of packet1, the third is the size of packet2, etc. Can be nullptr if auxValues is also nullptr. The user is in charge of releasing the auxValuesCount buffer with simReleaseBuffer(*auxValuesCount).
USAGE EXAMPLE:
float* auxValues=nullptr;
int* auxValuesCount=nullptr;
float averageColor[3]={0.0f,0.0f,0.0f};
if (simHandleVisionSensor(visionSensorHandle,&auxValues,&auxValuesCount)>=0)
{
if ((auxValuesCount[0]>0)||(auxValuesCount[1]>=15))
{
averageColor[0]=auxValues[11];
averageColor[1]=auxValues[12];
averageColor[2]=auxValues[13];
}
simReleaseBuffer((char*)auxValues);
simReleaseBuffer((char*)auxValuesCount);
}
|
C/C++ return value
|
number of detections (number of vision sensors that triggered a detection), -1 in case of an error
|
Lua synopsis
|
int detectionCount,float[] auxiliaryValuePacket1,float[] auxiliaryValuePacket2, etc.=sim.handleVisionSensor(int visionSensorHandle)
|
Lua parameters |
Similar to the C-function counterpart
|
Lua return values
|
detectionCount: number of detections (number of vision sensors that triggered a detection)
auxiliaryValuePacket1: default auxiliary value packet (same as for the C-function)
auxiliaryValuePacket2: additional auxiliary value packet (e.g. from an image processing component)
auxiliaryValuePacket3: etc. (the function returns as many tables as there are auxiliary value packets)
|
Python synopsis |
int detectionCount,list auxiliaryValuePacket1,list auxiliaryValuePacket2, etc.=sim.handleVisionSensor(int visionSensorHandle) |
|