Calculating focal length of Raspberry Pi Camera

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. Mar 28, 2018 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 Mar 28, 2018 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 Mar 29, 2018 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. Mar 29, 2018 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. Mar 29, 2018 at 23:07