Vision sensor questions

Typically: "How do I... ", "How can I... " questions
Post Reply
nfys
Posts: 5
Joined: 06 Jun 2015, 15:43

Vision sensor questions

Post by nfys »

Hello,

I have some questions about the way perspective vision sensors are implemented in VREP.

1) I see there is only one entry in angle of view. Does this mean I cannot have different angles in x and y directions?
2) Is there a fixed focal length? I need a way to translate image patch size to imaged object size.

I noticed the answer to this question:
viewtopic.php?t=441&p=1581

But I don't feel it is clear enough in the sense that it doesn't provide a definitive answer as to what the focal length value of a vision sensor is. The focal length cannot be computed by the angle of view alone and I believe that in your implementation you must have a value for the focal length parameter to calculate the projection.

I understand that I could infer the focal length by placing a surface of known size at a known distance in front of the vision sensor and counting pixels but that would take time and probably produce inaccurate results.

Your help will be much appreciated.

Thanks in advance.

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

Re: Vision sensor questions

Post by coppelia »

Hello,

a vision sensor that operates in perspective mode has basically 3 important parameters (among others):
  • perspective angle
  • resolution X
  • resolution Y
Unless the resolution X and Y are same, the horizontal and vertical opening angles of your vision sensor will not be the same. In pseudo-code:

Code: Select all

ratio=resolutionX/resolutionY
if (ratio>1)
{
    angleX=perspectiveAngle
    angleY=2*atan(tan(perspectiveAngle/2)/ratio)
}
else
{
    angleX=2*atan(tan(perspectiveAngle/2)*ratio)
    angleY=perspectiveAngle
}
Now, you have following relationship between pixel position and angular value for that pixel position, where pixelPos varies between 0 and resolution, and anglePos between -angle/2 and +angle/2:

Code: Select all

anglePos=atan(tan(0.5*angle)*(2*pixelPos/resolution-1))
pixelPos=0.5*resolution*(1+tan(anglePos)/tan(0.5*angle))
Cheers

mgserafi
Posts: 3
Joined: 03 Jun 2016, 20:15

Re: Vision sensor questions

Post by mgserafi »

Hello

I was wondering how do you use the angular positions in order to get the x and y pixel position of an object given the position of object relative to vision sensor.
Essentially I want to go from camera space o image space.

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

Re: Vision sensor questions

Post by coppelia »

Hello,

have a look at my previous reply here above, that I have corrected/updated.

Cheers

gabriel.previato
Posts: 1
Joined: 18 Aug 2017, 19:26

Re: Vision sensor questions

Post by gabriel.previato »

Hello,

I still didn't get if it is possible to know a specific value for the focal length.
I'm implementing an algorithm for Robot Localization using cameras, and for that, I'm getting the distance from the robot to several landmarks. And for the algorithm that I'm using, I need the focal length value of the vision sensor.

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

Re: Vision sensor questions

Post by coppelia »

You can only express the focal length in pixels with a virtual camera. Which however only makes little sense. You should use the Field of View in your calculations. In V-REP you can use the opening angle or perspective angle to obtain the field of view, which is:

Code: Select all

ratio=resolutionX/resolutionY;
if (ratio>1)
    fov=2*atan(tan(perspectiveAngle/2)/ratio);
else
    fov=perspectiveAngle;
Cheers

slgrajeshwar36172
Posts: 5
Joined: 06 Nov 2019, 04:34
Location: iit patna
Contact:

Re: Vision sensor questions

Post by slgrajeshwar36172 »

sir,
what will be the formula to find the focul length in pixel. if we know the field of view and resolution of image.


thanks

Post Reply