Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Camera distance

Hello there,

 

I am working on a project for a class. Part of what I would like to do is have a webcam find a target and tell me how far away it is. What makes this more complicated, unfortunately, is A) I would like the distance measurement to be largely automated (I understand the clamp tool is the way to go for doing distance from camera but I am not sure how to automate it) B) The target is to be between 2 and 5 meters away from the camera. I have looked through nearly all of the example VI's but don't see any that work at distances greater than perhaps a foot.

 

The target I will be finding is up to me so obviously I want to pick the easiest thing which I would imagine to be a concentric ring "bulls-eye" pattern of about a foot square. At a distance of 2-5 meters, I have difficulty picking this object from the background through any means, let alone finding the distance it is away.

 

Thank you for your time in reading all of this and thank you in advance for your help,

 

-Kevin

0 Kudos
Message 1 of 4
(3,164 Views)

Here is a pattern I created a while back that I would consider searching for.  It provides rotation information as well as position information.  If you just need position, you could just use a 2x2 checkerboard pattern.  Deciding the size of the template is simple - make sure you can see the whole thing at the closest distance.  Make sure it is large enough to see the pattern at the far distance.  It is probably easier to use the smallest size that will work at the far distance.  Something that fits on a standard sheet of 8.5x11 paper is probably easiest - I would probably make the squares 3 or 4 inches square.

 

Rotation Template.png

 

The neat thing about these patterns is that you can use pattern matching, and it should work at any scale.  If you create the pattern template at the largest distance, and don't go all the way to the edges, it should work for any pattern that is larger (closer).  Geometric Pattern matching might work well.  Once you find it, measure the pattern by perhaps locating the edges of the black square.  The distance from the camera should be proportional to the size of the target.  You can verify it easily.

 

Bruce

Bruce Ammons
Ammons Engineering
Message 2 of 4
(3,162 Views)

Hi Bruce,

 

Thank you very much for your response as it has been very useful to me so far. I've managed to find that pattern in a variety of places and distances and the geometric pattern matching has worked very nicely. The only problem I've been running into is if the target is not facing the camera directly, as in if my camera is at an elevation of 600cm and the target is on the ground, geometric pattern matching has trouble finding the pattern. I imagine this could be solved by using a calibration for the distortion? I need to experiment more.

 

Also, I have had success using the clamp tool to find fairly accurate distances, but I'd like to "idiot-proof" my program so the user cannot make the clamp area too large around a target and mess up my distances. So far my best idea of how to do this is to have the user "verify their target" while secretly making them use the magic wand tool and then setting a couple of additional geometric matches for the more common areas picked out by the magic wand. At any rate, I am now rambling so thank you very much for your help and any further suggestions are much appreciated.

 

-Kevin

0 Kudos
Message 3 of 4
(3,142 Views)

what sort of camera did you use?
Did you find anything with auto focus, or could you tun it off? 

0 Kudos
Message 4 of 4
(2,814 Views)