I have bumped into this statement in an Engineering journal. The statement is mentioned on right side example.

A 640x480 image with a horizontal FOV of 47 degrees gives focal length f = 740 pixels.

Please let me know the calculations behind this as I am very new to Computer vision.

  • 2
    The focal length is usually not measued in pixels. – Hermann Klecker Mar 13 '18 at 10:48
  • what kind of vision sensor is it? and this sentence doen't make much sense, because the unit of focal length is a distance. so here are some informations missing – Horitsu Mar 13 '18 at 10:48
  • Its MobilEye Vision sensor. Please have a look at this paper on the right side. yumpu.com/en/document/view/49159361/… – Code_Kid Mar 13 '18 at 10:55
  • 1
    I'm voting to close this question as off-topic because it is about machine vision in a context that is not applicable to creative photography. – Michael C Mar 13 '18 at 11:20
  • 1
    It's indeed not creative photography, but still photography. And it could be useful to help understand what happens in a camera. So i answered it – remco Mar 13 '18 at 11:58

It's basic geometry: you have a right angle triangle, with half the FOV as one of the angles (a), and half your image size as the opposite side (A). To calculate the focal length F, use tan(a) = A/F,
which gives F = A/tan(a).

The article specifies that the horizontal FOV is 47°, so we have to use
A = 640/2 = 320, a = 47°/2 = 23.5°, which give F = 736 pixels.

As your sensor size is given in pixels (assumed square pixels!), your focal length will also be in pixels. To get it in a more usual unit (m), you need to know the pixel size.

  • 1
    "rectangular triangle"...?? Maybe I need to re-take geometry class... – twalberg Mar 13 '18 at 12:04
  • 1
    Not 100% it's the proper term: I mean a triangle where one of the angles is 90° – remco Mar 13 '18 at 12:14
  • @remco Thanks a lot for the help. It helped a lot. A explanation with a picture would have been more helpful to clear the 'rectangular triangle' confusion, – Code_Kid Mar 13 '18 at 12:36
  • @remco That's a right triangle. – mattdm Mar 13 '18 at 19:05
  • @mattdm thanks, that kind of things reminds me that English is my 2nd language ;) – remco Mar 13 '18 at 20:34

I will use that image to illustrate why focal length can be measured in pixels and what they mean by those numbers:

enter image description here

The triangles (large and small) are similar, that is angles are the same. So Angle of view will be the same as top angle (at the lens) of the smaller triangle. From that, since you know what sensor size and angle of view is, you can calculate focal length in pixels, as @remco calculated for you.

In fact, units of the sensor size should be exactly the same as units of the focal length to make sense of F=A/tan(a). What you can get from that is, if you have bigger pixels (in cm), you will need larger focal length (in cm) for same field of view and number of pixels.

  • That could be applicable only if speaking very relatively, but any number computed from pixels is generally inapplicable to sensor sizes in mm. Pixels can vary (by pixel or sensor size design or by resampling), so the same focal length would have various numbers in pixels, none of which reflect anything real. Why would we use pixels when we can stay in the real world? Even if if trying to compute object size in image from pixels, what makes the two triangles similar is that sensor size and focal length are both in mm, and working distance and field or object size are both in feet or meters. – WayneF Mar 13 '18 at 21:26
  • Thanks a lot for the pictorial explanation. Since you have used the term Sensor size rather than image size, does both of them equal? Isn't different image sizes configurable from a same image sensor? – Code_Kid Mar 14 '18 at 2:01
  • @Code_Kid sensor size is 300pixels or 500mm can be true at the same time. You can enlarge image from 300 pixels sensor to 5000 pixels, it's called interpolation – aaaaa says reinstate Monica Mar 14 '18 at 4:04
  • @WayneF Focal length in mm Fx(mm) = focal length fx(in pixels)*(Image sensor width (in mm) / Image width (in pixels)); Similarly Fy(in mm) = focal length(in pixels) * (Image sensor height(in mm)/Image height(in pixels)). Hope this makes sense and what remco mentioned in his answer's last statement. – Code_Kid Mar 14 '18 at 9:30
  • The factors are distance and field size (both feet or meters), and sensor size and focal length (both mm). This makes the equal opposing angles of the two triangles. We can compute any one if we know the other three. Relative focal length in pixels cannot be specified as a given, it can only be computed from the other three, but pixels will differ with every sensor or pixel size. What possible use could it have? Relative focal length in pixels is never seen in the real world, it can only apply to one specific situation. Focal length in mm is the valid parameter, is same in any situation. – WayneF Mar 14 '18 at 14:40

It is what Hermann said, focal length is NOT measured in pixels. I strongly doubt the engineering journal said focal length was pixels.

What you need to know for field of view is the camera sensor size (or film size) measured in mm. You must compute with sensor dimensions in mm.

There is a calculator that will do this at https://www.scantips.com/lights/fieldofview.html (Option 6). The geometry is shown at bottom of that page, however, you must use Trig for angles.

  • Actually, the cited article did state the focal length in pixels. And a pixel is a perfectly acceptable unit of length in this context (not all that different from the inch, link, or Å). And e.g. CSS/HTML also allows 'pixels' as a unit and you can freely mix them with other units like the pica or em, see the 'calc()' function. – remco Mar 13 '18 at 16:56

The angle of view is calculated by trigonometry.

Generally the focal length will be a known value as will be the measurements of the rectangular image.

To calculate the angle of view: Find ATAN (arc tan) of ½ the measurement divided by focal length, them multiply by 2.

Solve for the 640 dimension ATAN (640 ÷740 X 0.5) X 2 = ATAN (0.4324) X 2 =23.3852 X 2 = 46.77°

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.