Display Image from Vision Sensor

Typically: "How do I... ", "How can I... " questions
Post Reply
davide.barchi
Posts: 5
Joined: 28 May 2018, 08:52

Display Image from Vision Sensor

Post by davide.barchi » 22 Jun 2018, 11:20

Hi, i've encountered a problem similar to viewtopic.php?t=5565

Basically, I have to read an Image from a Vision Sensor and then display it through a floating view. The final goal would be display the depth buffer coming out from the sensor through a grey scale image.

In order to do that, I would like to check first of all the the possibility to display a general Image, so I've done the folliwing operations:

1) Add the sensor that will read the image
2) Add a second vision sensor with an associated floating view, checked its "External Input" and "Explicit Handling"
3) run the bottom code in a non thread child script:

Code: Select all

function sysCall_init()
    VisionH15Handle = sim.getObjectHandle('VisionH15') -- this will read the image
    DispalyHandle = sim.getObjectHandle('DisplayVisionSensor') -- this will display the image
end

function sysCall_actuation()
    imageBuffer=sim.getVisionSensorCharImage(VisionH15Handle,0,0,0,0,0)
    if(imageBuffer == nil) then
        print('error')
    end
    rv = sim.setVisionSensorImage(DispalyHandle,imageBuffer)
    print('debug',rv)
end


However, the output is always:
debug,-1
debug,-1
debug,-1
debug,-1
debug,-1
debug,-1
debug,-1
......

What am i missing?
Davide

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

Re: Display Image from Vision Sensor

Post by coppelia » 23 Jun 2018, 18:20

Hello,

are you sure the two vision sensors have the same resolution? Also, what happens if you use sim.setVisionSensorCharImage instead?

Also, you probably know that you can directly display the image or depth map of a vision sensor in a floating view, without the need to hand over the image to another vision sensor.

Cheers

davide.barchi
Posts: 5
Joined: 28 May 2018, 08:52

Re: Display Image from Vision Sensor

Post by davide.barchi » 25 Jun 2018, 07:36

coppelia wrote:
23 Jun 2018, 18:20
Hello,

are you sure the two vision sensors have the same resolution?

Cheers
Actually the problem was this one. Thanks!
coppelia wrote:
23 Jun 2018, 18:20
Hello,

Also, you probably know that you can directly display the image or depth map of a vision sensor in a floating view, without the need to hand over the image to another vision sensor.

Cheers
I know i can display directy an image in the floating view, what about the deph map?

Davide

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

Re: Display Image from Vision Sensor

Post by coppelia » 27 Jun 2018, 10:06

Yes, you can also directly display the depth map. In that case you first need to replace the filter Original image to work image with Original depth image to work image.

Cheers

Post Reply