Click here to Skip to main content
15,884,537 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I'm doing a hexacopter project and i will use a camera for position or distance estimation from the ground. The camera is mounted
underneath the hexacopter facing downwards towards the ground
Posted

You can't really estimate distance to an object using one camera. You need TWO of them, offset from each other a known distance, same as the your own eyes. Then you can compare the images and estimate a distance from that.

Look into the AForge library to help with some of this.


Actually, if all you're interested in is an altitude, look into a microcontroller and an ultrasonic sensor. It's much easier and lighter compared to what you're looking into.
 
Share this answer
 
v3
Comments
Sergey Alexandrovich Kryukov 4-Nov-14 17:36pm    
Strictly speaking, this is impossible. Even with two cameras, there can be ambiguity. Such problems are sometimes solved due to the fact that there are well-known objects with known sizes. Nevertheless, they can be faked, specially for the purpose of confusing perception of space.

Now, as to the stereo effect based on the vision of two eyes, it's role of often highly exaggerated. For a human vision (and optical settings of most cameras are designed to be more or less close to human perception), so called "practical infinity" is estimated to start at some 15 m. At this distance, neither focusing nor stereo effects don't help to estimate distance, people do it exclusively based on available experience and preexisting knowledge (and do a lot of big mistakes, by the way).

Anyway, my 5.

—SA
Sergey Alexandrovich Kryukov 4-Nov-14 17:51pm    
If the size of the recognized object is known, distance estimate is pretty easy, in many cases.
Please see my answer.
—SA
Dave Kreskowiak 4-Nov-14 23:39pm    
"The ground" isn't a well-known object. I doubt there will be any well-known objects in his particular application.

Frankly, it's a lot smaller and easier to use an ultrasonic sensor to get an altitude above ground level.
Sergey Alexandrovich Kryukov 5-Nov-14 0:40am    
I'm not sure. To me, the description does not clearly explain what is the object to be recognized, but I don't think it's "ground" (if some object is to be recognized, it is, in a way "well-known"). Probably OP mentioned ground to describe the setup. So, some distance measurement could be possible.

It's a right idea to use something else, not camera, for distance estimation. It can give much better accuracy. Lidar, ultrasonic sensor...

—SA

Please see my comment to Solution 2.

You can calculate the distance to some object, if you know precisely:

  • The natural (real-life) size of the object you recognized.
  • Sizes of the working area of your camera sensor (in both sm/mm and pixels).
  • Exact optical characteristics of your lens (at least at the given position of the zoom if zoom is available), as well as the location of its back (image) focal plain relative to the sensor; these characteristics change with focusing and zooming. In many cases, you can use technical specs of the lens and EXIF data, to figure out working position.

In many (but not all) cases, you can use simple approximation of "thin lens" to get sufficient accuracy. Then this is a matter of simple optical calculations at the level of high school course of physics. Please see: http://en.wikipedia.org/wiki/Lens_%28optics%29#Thin_lens_equation[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900