of an Object in a photo image

This is rather specialized, but people do ask how to determine or measure the distance or size of an object or subject 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 find distance or size of an object in a photo, but you must know the following things about the situation:

- The lens focal length that the camera image used.
- The sensor size in the camera, in mm.
- The sensor size in the camera, in pixels (image size).
And then,

**two of these next three**, to compute the other: - The size (pixels) of the actual Object in the image, width or height.
- The real life size of the Object, the actual or approximate estimated Width or Height size dimension, in feet or meters. Not necessarily the "subject", but some known object there. Its distance and size must be in the same units (feet or meters).
- The distance to that object from camera.

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. If you are using Width as Height then use sensor Width, and 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, unless you change something. But each option is recomputing and overwriting its own result goal, even if it is the same result.

Example: The calculator initial defaults match this photo example. The tape on the floor in the image 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. Cameras don't know distance, they only know how much the lens focus is rotated, but with zoom and internal focus changing everything internally, sometimes calibration must be hopeless, and the cameras distance report can be a real crap shoot (often worse than useless). If you're going to rely on the distance in the Exif, I suggest you first verify the accuracy of your lens, at least at both moderate and distant focus, and at both wide and telephoto zoom (see more details of my complaining about this).

The door measures 80 inches tall, 6.67 feet (or the size of some 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.

**Sensor size**: Specs for simple cameras rarely tell us sensor size, not in any meaningful way, and crop factor is likely more accurate then. DSLR normally do show detailed specifications.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.- Phones are not big on telling camera specifications, but compact cameras often at least tell us Equivalent focal length (compared to 35 mm film cameras). And then
**crop factor can compute sensor size**for us. For example, crop factor can be determined if focal length is described this way: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. These are the focal lengths at both zoom extremes. The focal length actually used in this photo likely will be in the Exif data. But from these equivalent numbers, we know this crop factor is

**25 mm/4.5 mm or 450 mm/81 mm, either one divided is 5.55 crop factor**(ratio of Equivalent/Real focal length).One calculator choice can compute sensor size from this Crop Factor. Since we know 35 mm film size, then this crop ratio specifies sensor diagonal size. In this case just mentioned, tell the calculator of this Crop Factor 5.5 and 4:3 Aspect ratio (4:3 for almost all compacts or phones), and it will compute and show sensor size of 6.29 x 4.72 mm. However, note that HD video shots are 16:9, a different size than still pictures in a 3:2 or 4:3 still camera, but the Crop Factor choice handles this.

Knowing Aspect Ratio - if your camera takes images so that (image width in pixels) / (image height in pixels) is 1.333, then the Aspect ratio is 4:3. If the division is 1.5, then the Aspect ratio is 3:2. And if 1.778, then it is 16:9 HD video shape.

- Or (not literally being serious), if you do know focal length accurately, and if you can measure the cameras field of view (the horizontal and vertical dimensions that it sees, at at least a few feet distance), then there's a calculator that can compute Sensor Size (Option 8 there).

- Phones are not big on telling camera specifications, but compact cameras often at least tell us Equivalent focal length (compared to 35 mm film cameras). And then
**Focal length**: the marked focal length may be a rounded number, often to 5 or 10 mm increments. And focal length applies to infinity distance, and will be a little different than marked if when focused up close. Actual focal length will be very different for macro work, at least a meter or two is necessary here. Focal length is not really a precise number, but this calculation will be as accurate as your data.If it's a still photo image (not a movie file),

**the focal length used should be in the Exif data**, which you can see there. This will likely be in the extended Manufacturers Data section, meaning, you may need a good Exif viewer to find it (see a good free one here). If a camcorder, and if you think you can duplicate the first focal length (maybe the default focal length), maybe you can take any still picture with it now, and see that focal length in its Exif data (of the still image).The 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. But if any Digital Zoom effects are in play, then that is cropping, and all bets are off.

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 really should be the original image from the camera. If you cheat on the calculator, it will cheat on you. :)

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:**

Object height on sensor (mm) **/** focal length (f, mm) **=** Real Object height (feet) **/** Distance to Object (d, feet)

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:

Distance to Object (d, feet) **=** Real Object height (feet) x focal length (f, mm) **/** Object height on sensor (mm)

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

Object height on sensor / Real object size = focal length f / Distance to Object d

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.

- The focal length is a nominal number, not precisely exact. And the marked focal length applies at infinity, and it will be a little different if focused close, so the focus distance should not be too close, at least a meter or two.
- Simple cameras typically do not give specifications about the sensor size in mm (the 1/xx inch number is near meaningless). And the 16:9 video height in 4:3 or 2:3 still cameras will be a shorter partial height too. However crop factor can compute sensor size.
- Camcorder 16:9 simply fits the full view circle from the lens. But other movie modes (in compacts, phones, DSLR) have to fit into the 4:3 or 3:2 format that is otherwise imposed. The 16:9 width cannot be wider than the still picture frame size. But it may be less, and may be unknown.

Menu of the other Photo and Flash pages here