sim.getVisionSensorDepthBuffer

Typically: "How do I... ", "How can I... " questions
Post Reply
Kamal99
Posts: 15
Joined: 29 Mar 2022, 21:01

sim.getVisionSensorDepthBuffer

Post 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

coppelia
Site Admin
Posts: 10505
Joined: 14 Dec 2012, 00:25

Re: sim.getVisionSensorDepthBuffer

Post 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

Post Reply