Associate one vision sensor to two floating views (one for rgb and one for depth)

Typically: "How do I... ", "How can I... " questions
Post Reply
zhy149
Posts: 132
Joined: 14 Apr 2021, 20:18

Associate one vision sensor to two floating views (one for rgb and one for depth)

Post by zhy149 »

Hello,

I have a vision sensor in simulation and I know how to associate it with an RGB floating view, but I want to add another floating view to capture the vision sensor's live depth image, is there a way to do this?
Thank you!

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

Re: Associate one vision sensor to two floating views (one for rgb and one for depth)

Post by coppelia »

Hello,

you have 2 possibilities:
  • the easiest would be to use a second vision sensor that only handles the depth, where the first one only handles the RGB
  • the recommended one: use a secondary, passive vision sensor with the same resolution as the original, and associate it with the second floating view. Make sure that passive sensor is explicitly handled. Then, attached to your original vision sensor, use this code that simply copies the RGB to the passive sensor, and switches to the depth image, e.g.:

Code: Select all

function sysCall_init()
    passiveSensor=sim.getObject('/passiveSensor')
end

function sysCall_vision(inData)
    local rgb=sim.getVisionSensorCharImage(inData.handle)
    sim.setVisionSensorCharImage(passiveSensor,rgb)
    simVision.sensorDepthMapToWorkImg(inData.handle)
    simVision.intensityScaleOnWorkImg(inData.handle,1.000000,0.000000,false)
    simVision.workImgToSensorImg(inData.handle)
end
Cheers

Post Reply