48

Is it possible to measure distance to object with phone camera?

I mean, in my application I start the camera, facing the camera to the object (lets say house) and then press the button and it calculates the distance and shows me in screen.

If it's possible where I can find some tutorial or information about it?

Lii
  • 11,553
  • 8
  • 64
  • 88
evilone
  • 22,410
  • 7
  • 80
  • 107
  • 21
    hey smartphone, manufacturers! time to add a laser range finder to your sensors! – Brian Sweeney Oct 27 '11 at 18:53
  • 1
    Leica Disto D810 laser distance meter : http://ptd.leica-geosystems.com/en/Leica-DISTO-D810-touch_104560.htm Leica Disto app : https://play.google.com/store/apps/details?id=de.ffuf.leica.sketch&hl=en – GuruM Nov 26 '13 at 11:41

10 Answers10

73

I accept the question has been answered adequately (with the obvious caveats of requiring level ground and possible accuracy problems) but for those who don't believe it can be done or that it needs a video camera, let me explain the low-level math needed to do it....

alt text

The picture above shows me standing outside my house. The horizontal (d) is the distance I want to measure and the vertical (h) is the height above the ground at which I'm holding the camera. In this case 'h' is a known value when I'm holding the android camera at eye-level (approx 67 inches or 1.7 metres). When I tilt the camera to aim it directly at the point my house meets the ground, all the software needs to do is work out the angle (a) relative to vertical and it can calculate 'd' using...

d = h * tan a
Squonk
  • 48,735
  • 19
  • 103
  • 135
30

Well you should read how ithinkdiff.com "measures" the distance:

Uses the angle of the iPhone to estimate the distance to a point on the ground. Hold the iPhone in front of you, align the point in the camera and get a direct reading of the distance. The distance can then be used in the speed tool.

So basically it takes the height of where you hold the phone (eye-level), then you must point the camera to the point where object touches the ground. Then the phone measures the inclination and with simple trigonometry it calculates distance.

This is of course not very accurate. It gets less accurate the further the object is. Also it assumes that the ground is level.

waldyrious
  • 3,683
  • 4
  • 33
  • 41
Peter Knego
  • 79,991
  • 11
  • 123
  • 154
10

Nope. The camera can only give you image data and an image alone doesn't give you enough information to give you depth information. If you had multiple images that you had location information for or even video you could then process it to triangulate the distance, but a single image alone would not be enough to give you a distance.

Daniel DiPaolo
  • 55,313
  • 14
  • 116
  • 115
  • But with videocamera it is? I want to develop application like this on iPhone http://www.ithinkdiff.com/turn-iphone-speed-measuring-gun-speedclock-download/ – evilone Jan 03 '11 at 21:29
  • 1
    Well, it's not quite as simple as "push button, get distance", but it would be more likely to be possible. But it'd still require you to have information about the location at various points throughout the video. If you took video of a wall with a one foot solid white circle painted on it, starting at 10 feet away and closing to 5 feet, you could use image processing/geometry to figure out how far away that circle was. For your purposes the general answer is "no". – Daniel DiPaolo Jan 03 '11 at 21:31
  • I added link to video what I want to achieve. If it's possible with iPhone, I think it's possible with Android. But I need a start, where to begin with. – evilone Jan 03 '11 at 21:33
  • You'll note that in the very description of that product that they require you to put in the distance to the object being measured. "Uses the camera to detect and analyze motion: Set the distance to the object you want to measure ..." – Daniel DiPaolo Jan 03 '11 at 21:35
  • @Daniel But in video they measure the distance. – evilone Jan 03 '11 at 21:41
  • They measure the change in distance over time based on lots of information that the user has to provide. If you rephrase the question to: "can I calculate change in distance over time given a video of an object, the distance to that object, and the approximate size of that object" then the answer is yes. The answer to your question is "no". Their "distance estimator" tool likely uses a lot of wild-ass assumptions about lots of things and you'll note that it is an "estimate". – Daniel DiPaolo Jan 03 '11 at 21:43
6

You can use the technique used by our eye to get perspective of depth and distance.

1) Get 2 images of the same object from two different camera positions.

2) The distance or pixels between object in 2 images is inversely proportional to distance between camera and object.

The implementation is available at https://github.com/agnelvishal/Distance-between-camera-and-object Here is the research paper http://dsc.ijs.si/files/papers/S101%20Mrovlje.pdf

Agnel Vishal
  • 564
  • 6
  • 13
2

You have the angle in the phone's accelerometer. If you calculate the tangent of this angle and multiply it by the height of the camera lens, you get the distance.

Peter O.
  • 32,158
  • 14
  • 82
  • 96
Chase
  • 21
  • 1
0

I think by using FastCV you can calculate the distance between Camera and the object. In this You dont need to know the angle or the Position of camera that you are holding above ground Level. take a look at this question here

kendrelaxman
  • 439
  • 2
  • 8
  • 19
0

One way to achieve this is using the DPI's in your device. You can take a picture and calculate the height. But you'll need another object as a reference and then you will be able to know the problem with this method could be the perspective between the objects

0

I think it could be possible doing that using the phone camera. I know that the modern phones use lenses to focus on a object. If it is possible to know their focal length and their position(displacement) to focus on the chosen object it's also possible to determinate the distance.

HomoVafer
  • 301
  • 2
  • 12
0

I think this App uses the approach MisterSquonk mentioned (its free). Watch the "Trigonometry" technique.

intA
  • 497
  • 2
  • 10
  • 23
-1

No. Only with two cameras in stereo mode, like the xbox 360 kinect. It takes at least 3 points to triangulate distance.