Author Topic: how do i get distance from a webcam?  (Read 6621 times)

0 Members and 1 Guest are viewing this topic.

Offline sinistaTopic starter

  • Jr. Member
  • **
  • Posts: 14
  • Helpful? 0
how do i get distance from a webcam?
« on: November 12, 2010, 04:14:48 PM »
Hey,

the title says it all, how do i get distance from a webcam?

Its for a uni project my lecturer has said that I should have two markers in the distance that i can see, from these two markers i should be able to work out the position of where i am in the room,

I'm thinking about the stereo vision tutorial from the vision part of the site

http://www.societyofrobots.com/programming_computer_vision_tutorial_pt3.shtml

but instead of there being two cameras and one alien, there is two markers and a webcam which i suppose is the tutorial back to front,

so yeah, is this the way to do it or is there something else i should think about?

Thanks in advance

Gary.

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,944
  • Helpful? 99
Re: how do i get distance from a webcam?
« Reply #1 on: November 12, 2010, 07:14:08 PM »
With both markers in one video frame it is geometry, optical scaling and pixel pitch to calculate their distance.
Or center one marker in a video frame then pan the camera until the other marker is centered and use the camera pan angle change and geometry to calculate the distance.

Offline azy

  • Full Member
  • ***
  • Posts: 107
  • Helpful? 0
Re: how do i get distance from a webcam?
« Reply #2 on: November 12, 2010, 09:53:58 PM »
I'm in the process of building a very powerfull robotic vision system using a webcam and i have a few ideas that may help

1 Arrow navigation, helps solve the problem of which direction I'm looking in

imagine an arrow suspended in space, the tip has x,y,z coords and the tail has x,y,z cords. In order to really know where it is pointing you need all 6 numbers. If the head was a green sphere and the tail was blue sphere then with a bit of maths you can work out which way its pointing. If the shaft was 2ft long then in your image one of the spheres will look bigger than the other. This is also true if the closer sphere is partly obscuring the further sphere

distance can roughly be guessed if a spot was placed on a wall just by measuring its size.

Ideas.

Attach a simple laser pointer to your webcam. with the laser dot showing up in the middle of image.

If your camera can move, then you can scan the room with the laser, watching how the dot distorts, stretches ,brightens or fades
again with some clever maths you can build up a rough point cloud of the 3d environment around you

Attach a narrow beam torch to your webcam, by measuring the spread of light you can also get an idea of how far away the object that you are looking at is

The human eye is very sophisticated, it does things like defocusing and refocusing to work out distances as well as a dozen other clever tricks. a blurry picture has less complexity, details smoothed out. from this you could zoom in and out until you find the point with the sharpest contrast

We don't see what we see, we take a number of snapshots and a few frames of video and construct a virtual 3d world out of the combined best guesses. Fine tuning and experience helps eliminate noise and optical illusions. Leaving you with a stunningly accurate Virtual View of the world. Mother Nature FTW !


« Last Edit: November 12, 2010, 09:55:28 PM by azy »

Offline sinistaTopic starter

  • Jr. Member
  • **
  • Posts: 14
  • Helpful? 0
Re: how do i get distance from a webcam?
« Reply #3 on: November 13, 2010, 08:09:27 AM »
thanks for the reply's, I have been reading around and doing some maths and while I'm quite sure how I would get it to work without using a laser for one cam the two cam version seems to work out on paper at least,

and as long as you know the local length it seems to be quite accurate, which brings me to my next question if I have an auto focus camera does this change the focal length

for instance if I get a couple of  ( http://www.amazon.co.uk/Logitech-QuickCam-Pro-9000-Webcam/dp/tech-data/B000T5GMJE/ref=de_a_smtd )
logitech cams with a focal length of 3.7mm and they decide to auto focus will it will it cause my program to give false readings?

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: how do i get distance from a webcam?
« Reply #4 on: November 13, 2010, 10:49:28 AM »
Hi,

for instance if I get a couple of [...] logitech cams with a focal length of 3.7mm and they decide to auto focus will it will it cause my program to give false readings?
No, you're maybe thinking of zoom, which do change the focal length.
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

Offline sinistaTopic starter

  • Jr. Member
  • **
  • Posts: 14
  • Helpful? 0
Re: how do i get distance from a webcam?
« Reply #5 on: November 13, 2010, 12:30:59 PM »
brilliant cheers Soeren, so do these cams look good for the purpose, or can anyone recommend any other for roughly the same price?

Offline azy

  • Full Member
  • ***
  • Posts: 107
  • Helpful? 0
Re: how do i get distance from a webcam?
« Reply #6 on: November 14, 2010, 01:27:07 AM »
I have the logitech Logitech Quickcam Pro 9000 webcam

You can set it to autofocus, or in the software set the focus with a slider (there is no manual dial ring for focus)

Other features, single/multiple face tracking right light, contrast , brightness, gain, coloursaturation , virtual tilt and pan , zoom, HD Video , Black and white , and a some other filters. video, option in software to use an external mic. (all web cam mic's are crap, Logitechs pops n crackles if the volume increase rapidly, shame cos its a very good webcam mic otherwise....other user noted this mic's flaw too) Cant beat an external mic so no biggie. One of the things u learn as u go along.

With right light on , images are very good in typical lowlight indoor settings. Of course if u are trying to analyze images with some code you have written any auto this or auto will have to be turned off or the auto changes may make a mockery of you algorithms.

Is it worth the money  ? Not sure, but the quality is going to be head and shoulders above 5 buck cams especially indoors & it has loads of features. I can't wait to throw it in the bin, but that will require me finding a kikarse web cam that doesnt have issues. Sugestions on a postcard plz. I love the quality and the features, im just getting too old to deal with tech that has issues lol

Initially i wanted a HQ camera, but then realized that the more pixels and colours you have to analyze with software the longer it takes.My 2 cents, The logitech joins a growing list of technology , great that it is, still leaves much to be desired  

note comes with the usual wondersoft bloatware that looks like its install a terabyte of crap all over your HD , does work plug n play without the cd, and u can just install the core drivers on the cd as an option


Logitech QuickCam Pro 9000 Review (Part 1/4)

well worth watching this video if you are unfamiliar with the ins and outs of webcams
« Last Edit: November 14, 2010, 02:24:02 AM by azy »

Offline sinistaTopic starter

  • Jr. Member
  • **
  • Posts: 14
  • Helpful? 0
Re: how do i get distance from a webcam?
« Reply #7 on: November 14, 2010, 02:29:36 PM »
ideal cheers for the vid :)

 


Get Your Ad Here