Getting Depth Image
Posted: 02 Dec 2023, 01:29
Hi everyone,
I'm trying to get the depth image taken by the vision sensor with an external Python script. I followed the steps provided in the previous questions in this forum. However, I cannot still retrieve the image I want.
The procedure I follow in the external script is like this:
First, the vision sensor is activated by using "detectionCount,_,_= sim.handleVisionSensor(visionSensorHandle)". Then the depth buffer is retrieved using: "depth, res = sim.getVisionSensorDepth(visionSensorHandle,0,[0,0],[0,0])"
After that, according to the documentation on the website, this buffer is unpacked using: "unpackedDepth = sim.unpackFloatTable(depth, 0,0,0)"
However, I have two problems right now:
1) the unpacked depth list does not make sense, and all the values in this list are the same, and the format of how the values are stored is not clear.
2) the unpacking process takes a long time, around 10 seconds, which is not good for my project.
Also, the child script for the vision sensor in the scene is like this:
"--lua
sim=require'sim'
simVision=require'simVision'
function sysCall_init()
end
function sysCall_vision(inData)
local retVal={}
retVal.trigger=false
retVal.packedPackets={}
simVision.sensorDepthMapToWorkImg(inData.handle)
simVision.intensityScaleOnWorkImg(inData.handle,1.000000,0.000000,false)
simVision.workImgToSensorImg(inData.handle)
return retVal
end
"
All I need is the depth information in a 2D array in the range of 0-255.
I'm trying to get the depth image taken by the vision sensor with an external Python script. I followed the steps provided in the previous questions in this forum. However, I cannot still retrieve the image I want.
The procedure I follow in the external script is like this:
First, the vision sensor is activated by using "detectionCount,_,_= sim.handleVisionSensor(visionSensorHandle)". Then the depth buffer is retrieved using: "depth, res = sim.getVisionSensorDepth(visionSensorHandle,0,[0,0],[0,0])"
After that, according to the documentation on the website, this buffer is unpacked using: "unpackedDepth = sim.unpackFloatTable(depth, 0,0,0)"
However, I have two problems right now:
1) the unpacked depth list does not make sense, and all the values in this list are the same, and the format of how the values are stored is not clear.
2) the unpacking process takes a long time, around 10 seconds, which is not good for my project.
Also, the child script for the vision sensor in the scene is like this:
"--lua
sim=require'sim'
simVision=require'simVision'
function sysCall_init()
end
function sysCall_vision(inData)
local retVal={}
retVal.trigger=false
retVal.packedPackets={}
simVision.sensorDepthMapToWorkImg(inData.handle)
simVision.intensityScaleOnWorkImg(inData.handle,1.000000,0.000000,false)
simVision.workImgToSensorImg(inData.handle)
return retVal
end
"
All I need is the depth information in a 2D array in the range of 0-255.