views:

227

answers:

2

Let's say we have an image like so

alt text

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.

A: 

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"

CrimsonX
A: 

Since you can assume that a bookshelf is parallel to the one below it, then the actual distance between bookshelves is equal at any point. You can determine that after X pixels of depth, the perceived height decreases by Y %. You should be able to establish a clear pattern quickly. All of the parallel lines and right angles in your actual space will make the math easy.

Plot some starting points at the beginning and end of each bookshelf. You can find the relevant math topics here:
http://en.wikipedia.org/wiki/Slope
http://en.wikipedia.org/wiki/Cartesian_coordinate_system

Dinah