Page 1 of 1

Vision sensor questions

Posted: 17 Sep 2015, 13:12
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.

Re: Vision sensor questions

Posted: 17 Sep 2015, 17:44
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

Re: Vision sensor questions

Posted: 01 Sep 2016, 04:45
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.

Re: Vision sensor questions

Posted: 02 Sep 2016, 11:09
by coppelia
Hello,

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

Cheers

Re: Vision sensor questions

Posted: 10 Sep 2017, 16:54
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.

Re: Vision sensor questions

Posted: 12 Sep 2017, 14:37
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

Re: Vision sensor questions

Posted: 18 May 2020, 08:22
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