Page 1 of 1

sim.getVisionSensorDepthBuffer

Posted: 05 Apr 2022, 12:32
by Kamal99
Hello,

I have some problem with using sim.getVisionSensorDepthBuffer
I would like to get the depth info from the camera
  • Using CoppeliaSim V4.3.0., (rev. 3)
  • Using ZMQ remote API (Python)
I have the below code

Code: Select all

self.cam_handle = self.sim.getObject('/Vision_sensor_persp')
raw_image, resX, resY= self.sim.getVisionSensorCharImage(self.cam_handle)
print("before")
depth_buffer = self.sim.getVisionSensorDepthBuffer(self.cam_handle) 
print("after")
I am able to get the RGB image, but once it gets into sim.getVisionSensorDepthBuffer. It gets stuck there, I mean the execution prints lastly before
And, Coppeliasim gives this message in a pop-up window ZMQ remote API server@addOnScript: abort execution

Thanks for assist,
Kamal

Re: sim.getVisionSensorDepthBuffer

Posted: 05 Apr 2022, 15:51
by coppelia
Hello, please try to add sim.handleflag_codedstring to the handle in sim.getVisionSensorDepthBuffer, like in:

Code: Select all

self.cam_handle = self.sim.getObject('/Vision_sensor_persp')
raw_image, resX, resY= self.sim.getVisionSensorCharImage(self.cam_handle)
print("before")
coded_depth_buffer = self.sim.getVisionSensorDepthBuffer(self.cam_handle+sim.handleflag_codedstring) 
print("after")
depth_buffer=[]
for i in range(int(len(coded_depth_buffer)/4)):
    depth_buffer.append(struct.unpack('<f',coded_depth_buffer[4*i:4*(i+1)])[0])
If you don't do that, and your sensor has a relatively large resolution, then things might get quite slow. Let me know if that changes something.

Cheers