How to correctly use sim.checkVisionSensor?

Typically: "How do I... ", "How can I... " questions
Post Reply
mysaki
Posts: 1
Joined: 18 Dec 2023, 08:05

How to correctly use sim.checkVisionSensor?

Post by mysaki »

I want to know if my tracking target is in the image, so I used
sim.checkVisionSensor in my code. But, its output keeps 0 even when the
tracking target is in the picture
my code in the child script of kinect is as follows:

function sysCall_init()
depthCam=sim.getObject('./depth')
depthView=sim.floatingViewAdd(0.9,0.9,0.2,0.2,0)
sim.adjustView(depthView,depthCam,64)

colorCam=sim.getObject('./rgb')
colorView=sim.floatingViewAdd(0.69,0.9,0.2,0.2,0)
sim.adjustView(colorView,colorCam,64)
c=sim.createCollection(1)
local o1=sim.getObject('/PioneerP3DX')
sim.addItemToCollection(c,sim.handle_single,o1,0)

end

function sysCall_cleanup()
end

function sysCall_sensing()
result,p1,p2=sim.checkVisionSensor(colorCam,c)
print(result)
end

function sysCall_vision(inData)
simVision.sensorImgToWorkImg(inData.handle)
simVision.workImgToSensorImg(inData.handle)
end

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

Re: How to correctly use sim.checkVisionSensor?

Post by coppelia »

Hello,

you can't simply call sim.checkVisionSensor and expect that your object(s) will be magically detected. You need to write an image processing function that can detect your object(s).

Have a look at the demo scene scenes/vision/objectTracking.ttt and the script attached to Vision_sensor to get an idea how this can be done

Cheers

Post Reply