Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I measure distances in an image?

Let's say we have an image like so

alt text
(source: curiousexpeditions.org)

Let's say we've already used filters and an edge detection algorithm in this pic. Now my goal is to measure distances (NOT actual distances, distance can be in any arbitrary unit) . eg: How do I find the length of the hall? (until the window)

Or the height of the bookshelves? How exactly do you place the "scale" and measure. I'm looking for ideas. However it would help if the answers were in terms of OpenCV.

like image 738
Laz Avatar asked May 21 '10 16:05

Laz


People also ask

Is there an app to measure something in a picture?

The camera uses augmented reality technology (AR) to easily measure length of any object with your smart phone camera.

How do I measure a distance in a picture in Word?

From Drawing Tool Shapes, drag the Measure tool shape onto the drawing page. Glue one endpoint of the Measure tool shape to one point you want to measure—the endpoint turns green to indicate it is glued. Then drag the other end to the other point. The measure tool shows exactly how far apart its end points are.

Can you calculate distance with a camera?

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.


1 Answers

It depends on what you're trying to do.

You mention you want to measure the height of the bookshelves. If its OK with you to consider the close area of the bookshelf "shorter" than the height of the end of the bookshelf at the end of the row, all you're looking for is to measure distance. Choose a unit of "pixels" and then measure the distance using the Pythagorean theorem. (x^2+y^2 = z^2)

What you're probably really looking for is to have the height of the near bookcase be the same as the height of the far bookcase. In that case, you have to have more information. You have to do a 2D -> 3D transformation: You have a 2D image and you need to reconstruct a 3D picture from that image. At that point, you need a 3rd piece of information, since you want 3 variables (X, y, z) from 2 variables.

You can definitely do this with OpenCV if you properly calibrate the system and have a second reference point (for example, a laser line). This is known as a structured light approach - see this link for more information or google "machine vision structured light"

like image 99
CrimsonX Avatar answered Sep 30 '22 05:09

CrimsonX