2

This article claims you can calculate the focal length of the Pi camera with the equation:

F = (P x  D) / W

where:

  • W is width of known object
  • D is the object's distance from the camera
  • P the apparent width in pixels of the object in our camera's view

I conducted this test with my camera, and found a value very close to the author's of 543. Since the equation's units are pixels * distance / distance the resulting units of the focal length are pixels.

However, this contradicts other documentation on focal length which says its typically measured in millimeters, and the specs for the camera claim the focal length 3.60 mm.

What am I missing here? Why are there two different definitions for focal length that use completely different units? Which is the correct definition?

  • You can use DPI (dots per inch) to transform pixel to mm. However, I am not sure, which DPI value to use. – user1251007 Mar 28 '18 at 13:54
  • not sure of the significance, but the first article states you can calculate the perceived focal length - perhaps the key word there is perceived – Jaromanda X Mar 28 '18 at 23:50
  • I think both units are correct, and dependent on the context of the calculation. These might be helpful: photo.stackexchange.com/questions/97213/… -- frogprints.co.nz/help/focal.cfm – goldilocks Mar 29 '18 at 13:28
  • @goldilocks, One answer there strongly disagrees that FL is measured in pixels. And that seems intuitive, since there's no objective conversion between pixels and distance, as different displays have different pixel densities. – Cerin Mar 29 '18 at 17:29
  • OK, but this is a red herring. What is significant is not the units, but the angles. The real XY size of an image will be determined by the focal length and the distance from the lens. If you've used a physical zoom this is obvious -- you extend the focal length and the XY of the image decreases. So too with digital zoom. I presume this is important to you because you want to use it to determine how far something is from the camera? The problem with that is knowing exactly how big the object is (e.g., a baseball as a standard). If you can correspond pixels to mm it doesn't matter. – goldilocks Mar 29 '18 at 23:07
0

The simplest way to estimate the focal length of a camera in pixels, is to use the focal length in mm and the size of the pixel (both given in data sheet of any camera, make sure to use consistent units.. mm vs um). So, for pi v1 camera focal_length_pixels = 3.60mm / 0.0014mm = 2571.4px. for pi v2 camera, focal_length_pixels = 3.04mm / 0.00112mm = 2714.3px

This result should be good enough to use if you don't have any calibration parameters, however for best results it's best to calibrate the camera using standard procedures (checkerboard)!

As to why different units are used? Well, they are different units used to represent the same thing in different context. Focal length is a property of a lens, so lens manufacturer provides this number in millimeters (real units), since they may not know / care about the camera and resolution someone might use with the lens. Once you pair a lens with the camera sensor, you can actually use the sensor pixel size to convert any measurement to pixels. Since most computation in the image are done in terms of pixels, it makes sense to convert / compute the focal length (and principal point) in the units of pixels.

| improve this answer | |

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.