Is it possible to measure distance to object with camera?

evilone picture evilone · Jan 3, 2011 · Viewed 89.9k times · Source

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?

Answer

Squonk picture Squonk · Jan 4, 2011

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