0
\$\begingroup\$

From an answer to the Photo-SE question, How do I calculate the distance of an object in a photo?, the formula for calculating distance if we know the size of the object is given as:

$$ \textrm{Distance to object}(mm) = \frac{f(mm)\,\times\, \textrm{real height}(mm)\,\times\, \textrm{image height}(pixels)} {\textrm{object height}(pixels)\,\times\, \textrm{sensor height}(mm)} $$

Can I use this method for photos/frames made by Android cameras? And if I use landscape orientation for capture image do I still have to use sensor height or it should be width? (and also other parameters - object, image - width or height)?

\$\endgroup\$
4
  • \$\begingroup\$ Yes, same method, formula \$\endgroup\$ Commented Mar 13, 2017 at 15:17
  • 3
    \$\begingroup\$ I'm curious as to why you might think that an Android camera would be an exception to the basic formula. \$\endgroup\$
    – mattdm
    Commented Mar 13, 2017 at 15:54
  • \$\begingroup\$ @RomeoNinov so I always should use this formula even if I use an image with landscape orientation? I don't have to change to sensor height to width? \$\endgroup\$
    – user25
    Commented Mar 13, 2017 at 19:43
  • 1
    \$\begingroup\$ @user25 Clearly, use whichever dimension is appropriate for the orientation for "height". \$\endgroup\$
    – mattdm
    Commented Mar 14, 2017 at 1:23

1 Answer 1

2
\$\begingroup\$

This is actually a simple ratio problem you can solve easily with a basic calculator .
We can a trace light ray coming from the top of the object to the lens. We can a trace light ray coming from the bottom of the object to the lens. These traces describe a triangle. The base of this triangle is a trace from the center of the object to the center of the lens. This is called the object triangle.

Light waves travel through the lens and fan out tracing out a triangle called the image triangle. The two triangles are the same as to their angles thus the length of the sides and the base trace out similar triangles, all the angles are the same however the lengths and base are not the same but they have the same ratio.

Given your description you know two things about the image triangle. You know its height; this will be the focal length of the taking lens. You also known the length of its base; this is a measurement taken from the imaging chip’s height or width. Say the focal length is 6mm and the chips, height is 10mm. We can divide these values and find a ratio. Thus 10 ÷ 6 = 1.66. This is the ratio height to base.

From your description we known height of the object. The distance to the object is unknown. Since the object triangle and the image triangle are similar we can use the ratio we have just calculated to find the distance to the object.

Say the height of the object is 14 feet. The distance to the object will 14 X 1.66 = 23.24 feet.

\$\endgroup\$

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