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

F = (P x  D) / W


  • 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
    – goldilocks
    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.
    – Cerin
    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.
    – goldilocks
    Mar 29, 2018 at 23:07

1 Answer 1


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.

  • I took some measurement using a Pi V2 camera and found the focal length was varying wildly with distance. I'll go with your numbers as they are based more along with what is traditionally considered a focal length. The article cited appears to use perceived pixels based on a ratio of the subject object size in a printed picture. Mar 16, 2021 at 7:07

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