I am developing a robot which has a single arm and one webcam that acts as eye to it. The webcam captures the image of the object. But how to calculate the distance or depth of focus so that the robot can move to that particular distance and pick up the object. The information that i have is only the image of that object
"Depth of focus" is the range at which an object is focused by a lens. Most Webcams focus from a couple inches (maybe 6-8") to infinity. I'm not sure this is what you're looking for here, but maybe you could elaborate.
For general information about computer vision and track planning see this link, for starters (and follow the other links):
Well I think I know exactly what you need. If you're not familiar with Nuts and Volts Magazine, and Servo Magazine, I highly recommed you check them out, they have tons of excellent articles on all aspects of robotics and electronics from beginner through to advanced concepts.
There is one particluar set of articles by Robin Hewitt which was published over 5 issues of Servo in 2005 called 'The Gift of Sight'. In the articles Hewitt goes through all of the math and theory behind using a single camera for calculating depth and locating objects in space, and works step by step through an example application. He also goes into detail on how to create a 'home' marker that the robot can recognize and navigate to. These articles probably explain everything you need to at least give you a good grounding and some starting applications. The articles are in the July through November 2005 issues. You can purchase back issues for $5 each here:
formatting link
or you can also purchase a CD of back issues for $30 however it doesn't look like they have 2005 on CD available yet.
Even if you do buy the print issues it would only be $25 and the other articles are definitely worth the price. I guess I sound like a shill for them but I've been subscribed to both magazines for 2 years now and I have learned a slew of new concepts and technologies that I otherwise would not have been exposed to in online robotics forums.
These articles should be what you need, however one note: in order to calculate depth locations in the manner they do in the article you must have images from two different locations, so you may need to construct a mechanism for moving the camera locations. I think you can calculate using images that are only 6 inches apart so perhaps just a moving slider with the camera mounted to it. Although you may be able to calculate depth if you have some sort of visual cues in your frame of vision to reference relative to the target object. Good luck!
A simple method is to mount a laser pointer directly above or below the camera. Scan the center column of the image to determine where the laser hits the target. Then use trig to calculate the distance. Even easier, construct a look-up table by placing a target at known distances and measuring the pixel location. The look-up table would probably be more accurate (harder to mess up, and camera images usually have distortion).
PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here.
All logos and trade names are the property of their respective owners.