This is rather specialized, but people do ask how to determine the distance or size of an object in a photo image. The DSLR camera Exif data may tell you Focus Distance, except you should realize that the focus distance reported is often seriously incorrect, especially for zoom lenses. You surely want to verify what actual focus distance is required for this lens to report that distance at that zoomed value. And the focus distance might not even be the distance of interest.
The calculator here can determine distance or size, but you must know the following things about the situation:
And then, two of these next three, to compute the other:
The calculator will compute # 4, 5, or 6 from the other five values.
You need the original digital image. It won't work from a cropped image or a paper print (but it could be a resampled image). See some notes below about determining values.
Numbers only. A NaN result will mean an input is Not A Number. Decimal points are OK.
Please report ( Here ) any problem with the calculator, or with any aspect of any page. It will be appreciated, thank you.
You can use object size or distance in feet or meters, cubits, whatever... Be consistent, both will be in the same units. Sensor size and focal length are always in mm.
If camera is rotated up on end to portrait orientation, then reverse sensor width and height here. You are using Width as Height then (use sensor Width, call it Height).
The options will compute and change the appropriate field, where the Pink background appears. Any value already in the field you are finding will be ignored and replaced (by computing with all of the other fields). So when one of the three options has already computed the matching numbers, the other options with same numbers without change can only compute the same matches. No visible change then, except perhaps the slightest rounding differences (we have to round to one pixel). But each option is recomputing and overwriting its own result goal.
Example: The calculator initial defaults match this photo example. The tape on the image floor measures 30 feet, which will be the correct result. If any doubts, you can repeat a similar test.
Nikon D800 DSLR camera: Sensor 35.9 x 24 mm. 7360x4912 pixels. 60 mm f/2.8 D lens.
The Exif says this Focus distance was 3.76 meters, which is 12.33 feet (when it was in fact actually measured to be 30 feet). The focus point was on the door knob, center of the frame. And this was a 60 mm lens, not even a zoom lens, so sometimes the cameras distance report is a real crap shoot (often worse than useless).
The door measures 80 inches tall, 6.67 feet (or the size of many things might be reasonably estimated). In the original full size image, the cropped door is 2724 pixels tall (crop it, then look at image size).
So computing distance, the calculator input specified 24 mm sensor height, 60 mm lens, 4912 pixel sensor height, 2724 pixel object height, and 6.67 feet estimated real object height.
The tape on the floor measures 30 feet, and the calculator computes 30.07 feet (within 0.2%). That 0.07 foot is 0.8 inches. This distance is computed to the Thin Lens node somewhere in the lens, not really known (but this calculated value here is to it, and Not to the focal plane mark at rear of camera). I guessed the node was at the middle of lens, so that could be an inch error. Still, the accuracy seems very adequate.
The focal length in the EXIF says 59.9 mm, which calculates 30.02 feet (0.07%).
If using a simple compact or smart phone camera, or camcorder, you may not know all of the numbers, like maybe not the correct size of the sensor in mm. Knowing crop factor can substitute for it.
But seeing a specification that your sensor is 2/3 inch or 1/1.8 inch means nothing in terms of actual sensor size (it's just a way to NOT tell us how tiny the sensor size is). If you cannot come up with accurate sensor size as width x height in mm, then your best bet is to use crop factor, which probably is available.
Focal Length: 4.5 (W) - 81.0 (T) mm (35 mm film equivalent: 25-450 mm).
The W means widest angle zoom and the T means longest telephoto zoom. From these numbers, we know this crop factor is 25 mm/4.5 mm or 450 mm/81 mm, either one is 5.55 crop factor (ratio of Equivalent/Real focal length). This is due to sensor size, and since we know 35 mm film size, then this ratio specifies sensor diagonal size. One calculator choice can compute sensor size from this Crop Factor (independent of focal length). Note that HD video shots are a different size than still pictures in a 3:2 or 4:3 still camera, but the Crop Factor choice handles this.
Then simple cameras normally specify their minimum and maximum zoom focal length, but we don't know any other value. These do reset to one default focal length when turned on, and then we can zoom them wider or more telephoto. But often we use the default focal length, which we don't know, so manually zoom them to the widest or narrowest view first. But if any Digital Zoom effects are in play, then that is cropping, and all bets are off.
If it's a still photo image (not a movie file), the focal length should be in the Exif data, which you can see there. If a camcorder, and if you think you can duplicate the first focal length (maybe the default focal length), you can take any still picture with it now, and see that focal length in its Exif data (of the still image).
The image used cannot be cropped. because we lose the sensor size in mm. It cannot be printed, because we lose the object size in pixels. It should be the original image from the camera.
However, the small resampled image copy which is shown here is 450x300 pixels, and it can work too (only because the image is still full frame view, NOT cropped at all).
Resamples: The "frame size in pixels" becomes the resampled size, but the sensor size in mm remains the same. Then (in this resampled smaller image) the cropped door is 168 pixels tall, full image height is 300 pixels tall (still representing 24 mm in camera), and calculator says 29.76 feet (0.8%). Less precision in a smaller image or object due to less possible cropping accuracy, one pixel is more then. Still, even this is very near 30 feet.
Note this 168/300 pixels or 2724/4912 pixels is simply computing the size is 56% of the 24 mm height of the camera sensor. Then knowing 56% of the camera sensor height in mm, and also the real life height, and the focal length distance in camera, it calculates distance to the subject.
Note that 16:9 movie images in a 3:2 or 4:3 still camera sensor is a resampled situation. The DSLR sensor might be 24 megapixels and 6000x4000 pixels, but the movie frame is resampled to 1920x1080 (2.07 megapixels) or 1280x720 pixels (0.92 megapixels). For such resampled images, use the resampled frame size in pixels, not the full sensor size in pixels. Movies in a still camera is also a cropped situation, but it's a bit special, if we assume the sensor width remains the same. Very few still cameras give the sensor area size in mm used for movies, but assuming full width is a good guess, unless otherwise specified.
People ask about the math. The math is similar triangles, just equal opposite angles, which are similar height/distance ratios.
The math the calculator uses is from this diagram:
Basics of lens optics:
This is similar triangles in the diagram. The sensor size and focal length are both in mm, which is one ratio. The object distance and size are both in feet or meters, which is another. Both are same equal ratio, so we have an equation. The units work out OK, we simply rearrange and compute for the unknown. If we know three of the factors, we can solve for the fourth one. The calculator will do this, but it needs your accurate numbers.
If desired, of course substitute meters for feet. And/or substitute width for height if appropriate. Just be consistent, and solve for the unknown.
Size of an object image on the sensor: If we determine that the object size (in pixels, height or width) is say 12% of the sensor dimension (in pixels, height or width), then we know the object image is also 12% of the sensor mm dimension. The calculators initial default numbers compute it as (2724/4912) x 24 mm = 13.3 mm object height. Then we must know the focal length in mm, and have a reasonable estimate of the real object size. Then the highlighted formula is all that you need to compute distance. But for any accuracy, we really do need to know accurate focal length and accurate sensor size (mm).
You don't have to convert any units if consistent. These are two ratios. Since mm cancels out in the ratio inside the camera, and feet or meters cancels out in the ratio outside the camera, then it's two unit-less ratios, both equal (geometry says so), so we have an algebra equation. To make it be right angles (to make this all be true), we normally divide both heights on both sides by 2 (representing the angle marked above). However, these 2's also cancel out, so it's not necessary in the math (unless using trig, then we must divide both by 2). Trigonometry can do it another way, but trig is unnecessary, unless you want to compute the angle itself. But in geometry, the two opposite right angles are equal, so in trig, the tangents are equal, therefore the ratios of (opposite side / adjacent side) are equal. Just saying, not making anything up. :)
The easy way is as shown. This math couldn't be easier. Rearranged to find distance is:
Or you can just use the calculator above. The calculator solves its example initial default case as 30.07 feet distance.
FWIW (bonus, informative fundamental). This same formula can be rearranged to be
This becomes obvious by definition when you recognize that it is similar sides of similar right triangles (then x 2 on both sides). Both of these ratios are "magnification" of the lens. In camera optics, lens magnification is of course (image size on sensor / image size in real life). Magnification is also f/d (if at 1:1, f and d are necessarily equal). These are obviously the same magnification, so these are obviously an equal equation, and we can solve for an unknown.
Assuming you want usable accuracy, the difficult part is determining accurate sensor dimensions and accurate focal length in the camera. I worry about your finding the right specifications, especially for compacts or phones. Vague questionable input gives vague questionable output. More bluntly, garbage in, garbage out. Read at the Field of View page for ideas about determining values. FOV is computed the same way, same equation of ratios.
Again, three points.