Society of Robots - Robot Forum

Electronics => Electronics => Topic started by: airman00 on August 02, 2007, 03:20:19 PM

Title: Distance Ranging Webcam- Using Sharpness?
Post by: airman00 on August 02, 2007, 03:20:19 PM
I downloaded RoboRealm (http://www.roborealm.com/) and found that whenever I move my camera close to an object or a wall the sharpness variable decreases. What happens is that the sharpness value will be like at around 1100 and then it will drop proportionally to the distance away until it reaches 300. Then it goes back up to 400. For those who do not know where the sharpness variable is, it is at the bottom in the folder named "Other"

My question is can this be  used for collision avoidance. I haven't done many tests but what I plan on doing is that once the sharpness drops below 300 my VB program gets a command that there is an object in front of it.

I am not very experienced with cameras so can anybody please explain what exactly sharpness is. How can you measure it? What is the difference between a sharpness of 1000 and 300. What does the 1000 represent and what does the 700 difference mean?
Thank You
Title: Re: Distance Ranging Webcam- Using Sharpness?
Post by: h3ro on August 02, 2007, 04:54:03 PM
It might work, try googleing "Hyperfocal distance". Not sure if that is exactly what you are looking for, but it might give some hints?
Also, you can try to find out how much parallax there is between things the camera sees. Parallax increases as objects get closer to the camera. This might be to advance or maybe not work for this kind of stuff.
Title: Re: Distance Ranging Webcam- Using Sharpness?
Post by: airman00 on August 02, 2007, 05:44:37 PM
The hyperfocal distance thing explains my situation exactly. As I approach an object the sharpness lessens due to the fact that I am not focusing the lens. This is not very precise but should work to avoid collisions. As for the parrallax, I was not able to find a program that calculates the parallax.
Title: Re: Distance Ranging Webcam- Using Sharpness?
Post by: paulstreats on August 02, 2007, 07:00:10 PM
parallax needs a picture taken from 2 places, you then compare the pictures and you can tell how far something is by the amount of parallax shift that occurs. This is how we calculate how far stars are from the earth up to a certain point before the paralax shift becomes too small.
 I dont know about using sharpness for distance ranging, but your best option is to use 2 cameras.
Title: Re: Distance Ranging Webcam- Using Sharpness?
Post by: airman00 on August 02, 2007, 07:27:22 PM
Any projects online that do what you are describing?
Title: Re: Distance Ranging Webcam- Using Sharpness?
Post by: Admin on August 04, 2007, 09:17:32 AM
Hmmmm neat idea!

airman00 please report your findings if you get it to work on a robot, Im curious . . .
Title: Re: Distance Ranging Webcam- Using Sharpness?
Post by: h3ro on August 04, 2007, 10:27:44 AM
Quote
parallax needs a picture taken from 2 places, you then compare the pictures and you can tell how far something is by the amount of parallax shift that occurs

No, you can work with pictures taken from the same place. But you need more then one picture.

I am no expert on this field, but I know that there are computer programs that track object from a film clip (For mixing CG elements with real footage). With a program like that you can get the info on how long the camera is from a specifics point.

You might want to check out how "Boujou" from 2d3 work. Not sure if it can be used in real time, but it might be possible to simplify the process to only finding distance instead of doing all the stuff a normal tracker program does?
Title: Re: Distance Ranging Webcam- Using Sharpness?
Post by: paulstreats on August 04, 2007, 10:41:49 AM
parallax is calculated by taking 2 pictures along a paralel plane, then using the half distance of that plane to work out 2 rightangled triangles, whose points meet at object. some quick trig will tell you the distance (also you get a bonus isosoles triangle to work with by combining the 2).
the greater the distance between the cameras or pictures result in greater accuracy. to measure distances of stars, a picture is taken from 1 end of earths orbit, then 6 months later it is taken from the opposite end to get the biggest plane distance and best accuracy. For a few metres though very little distance would be required (5 - 10 cm ish).

It would also be interesting to hear some results from your sharpess study (have you made a graph of sharpness threshhold against distance ? is it linear ? etc..)

Also what distance does it start losing sharpness? is it just very close?
Title: Re: Distance Ranging Webcam- Using Sharpness?
Post by: h3ro on August 04, 2007, 10:48:49 AM
Maybe parallax is the wrong word. I might be mixing something here. (Been doing a lot of photostiching lately) But do a search for objec tracking/machmoving and you will find what I am talking about, if your interested.
Title: Re: Distance Ranging Webcam- Using Sharpness?
Post by: paulstreats on August 04, 2007, 10:49:46 AM
Quote
No, you can work with pictures taken from the same place. But you need more then one picture.



Ive tried something similar a couple of years ago, but using just one picture, if you know the relational height of the camera, you can gain some data to form a right angled triangle:-

first you get the right angle

then the opposite side is the relational height of the camera

then you get the angle between the hyp and adj sides

it should be possible to calculate the distance like this provided you definately know the relational height of the camera.
Title: Re: Distance Ranging Webcam- Using Sharpness?
Post by: airman00 on August 05, 2007, 08:32:06 AM
I'm going to experiment with sharpness some more. The sharpness levels decrease from 1000 whenever it it like 6 inches away. What I plan on doing is to record the sharpness level  and then whenever the value is lower than 400 for more than 2 seconds , an object avoidance algorithm starts.
The reason for this is because the sharpness sometimes decreases to 300 only to go up to 500 when the camera moves a little. If a reading of under 400 lasts for more than 2 seconds, that shows that there is definetly an object in front.