5
\$\begingroup\$

I took a picture with Samsung S4 phone. Is it possible to determine the distance to the object on the picture?

The object is in focus. I looked at the JPG picture properties but could not find anything indicating to the distance. The focal length is fixed on this camera, it's 31mm in 35mm equivalent scale.

\$\endgroup\$
3
  • \$\begingroup\$ Do you know the size of the object? \$\endgroup\$
    – mattdm
    Commented Apr 12, 2014 at 11:29
  • \$\begingroup\$ @mattdm, no. In fact the reason I'm looking for a distance is to determine the size \$\endgroup\$ Commented Apr 12, 2014 at 13:56
  • 1
    \$\begingroup\$ That makes a big difference to the answers. \$\endgroup\$
    – mattdm
    Commented Apr 12, 2014 at 14:04

3 Answers 3

3
\$\begingroup\$

You can use this equation:

Distance of an object (in meters) =

   (focal length (mm) * object height (m) * image height (px))
   -----------------------------------------------------------
       (object height in image (px) * sensor height (mm))
\$\endgroup\$
2
  • 2
    \$\begingroup\$ See the comments. Size of object is not known. \$\endgroup\$
    – mattdm
    Commented Apr 12, 2014 at 14:04
  • \$\begingroup\$ @mattdm ah! well 2 unknown variables is a a problem, hope OP can estimate one of them. gotta work with what you have! \$\endgroup\$ Commented Apr 12, 2014 at 17:02
0
\$\begingroup\$

If it is in the file, exiftool will tell you.

If not, there is no easy way to tell the distance as cameras basically record angle information (in the picture - each pixel looks at a specific direction from an idealized center). If you have two or more photos from different viewpoints, then you could use PanoTools or similar tools to create a 3D mesh, and if you know some physical lengths then you could derive the distance to your object. (And you know some physical locations: your eye or camera level, and also the ground level, let's not forget it).

\$\endgroup\$
14
  • \$\begingroup\$ thanks, i'm surprised that cameras do not record auto-focus information. \$\endgroup\$ Commented Apr 10, 2014 at 15:17
  • \$\begingroup\$ Well - they record focal length and in-focus indicators. :-) But distance to subject needs triangulation, so two pictures. \$\endgroup\$
    – TFuto
    Commented Apr 10, 2014 at 15:33
  • \$\begingroup\$ @TFuto - it doesn't need triangulation. It does however need to know the exact stetting of the focus and the atmospheric conditions. Focus can change slightly based on humidity and such and generally lenses don't measure the exact position of the focus. If you did know the exact setting of the focus though, then the distance to subject can be calculated without any triangulating. \$\endgroup\$
    – AJ Henderson
    Commented Apr 10, 2014 at 19:50
  • 1
    \$\begingroup\$ @AJHenderson: Your reasoning is only valid if the person uses an extremely shallow depth-of-field, like one in microscopes (a long teleobjective is a good approximation). If he is using large DOF and not long focal length, the successive approximation or heuristics of focusing just gets a good enough focus lock. Imagine a very extreme scenario: an ultra wide angle lens. That has focus from 30 cm to infinity. So okay, you have a focus lock, but the relative error is so big, that data is not useful. My opinion... \$\endgroup\$
    – TFuto
    Commented Apr 10, 2014 at 20:25
  • 2
    \$\begingroup\$ Ah using the relative angles it the scene to determine relative angle. OK. I'm on board now. \$\endgroup\$
    – AJ Henderson
    Commented Apr 10, 2014 at 22:18
0
\$\begingroup\$

Most lenses don't measure the position of the focus, just which direction they need to move in order to reach focus. Therefore they can't measure the exact position of the focus. If the data isn't already in the EXIF information of the photo, then it likely is not able to be captured by the camera.

\$\endgroup\$
1
  • \$\begingroup\$ it makes a sense then, i was wondering why don't they report the position of the focus. i'd love to look at low level specifications of the phone cameras \$\endgroup\$ Commented Apr 10, 2014 at 19:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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