Let's Make Robots!

How to take distance using laser and camera

This is just a very simple way of getting a sense of distance

This may be extremely simple, but then again, some one out there might get inspired by this thing that I just "found", so I decided to share :)

Actually I started way more complicated with all sorts of moving stereo lasers :P 

But I got it down to this: Mount a laser to point in cameras direction and film. If the laser is placed on top, pointing a little down, the dot returned will be higher the closer the object is. I guess it should be fairly easy to be looking for that red dot's place on the axle, using some form of analysing software?

I myself have not gotten into using webcams on my robots yet, but when I do, it would be quite easy to test this method as a simple distance "sensor".

Due to all sorts of issues this may never be very precise (unless you have some really precise setup) - but it should give a very good indication of "close or far", will work on pretty long distances (specially inside, with shiny surroundings), and it will be cool.

And just to make sure you get me; I am talking:

The higher on y axis the red dot is, on the returned video, the closer the object. The power of the red dot is irrelevant.



Update: Oh, just realized; I have a "flat laser" - a normal red point laser that has a filter to it, so it beams out a flat long line. Using that causes you to see a "skyline" across the screen, with the highest point at where the closest object is.

I guess making video analyzing of such a line would be harder, but if possible, you could see everything on the X-axle, and not risk missing something like a wire in the air, that the pointer was not seeing :)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Nice one...  I'm guessing your "flat laser" is done with a reflector, but you can also spin the pointer and get the same effect.  I've done video processing before, but found the webcam I have is not very attuned to laser light.  Your's seems pretty bright in the video (happy camera).

Do you have other sensors which would be sensitive to 650nm light?  I've noticed a wiimote does a pretty good job, also an optical mouse is very sensitive - although the resolution is pretty poor, it could still be used as a rough range finder.

A line laser could be also used to estimate the angle of a robot to an encountering surface. A couple of years ago I did some experiments with a line laser and an electric drill to align the drill horizontal 90 degrees to the surface (wall). Vertical it can be done with a water level, but not horizontal. If the laser line on the left side of the drill had the same length as the laser line on the right side of the drill, the drill was at a 90 degree angle to the wall.

Can you make an illustration on that?


Oh! The with of the beam.. But I do not think I have such a sharp edge on the ends of the beams that it will be worth measuring. And then there is the camera that has to see the whole line. I think this may be hard, because how should the robot know that it is facing a flat surface, and it is not just a thing in the way. ? Hmm..

You need to get a better line laser :)


I'm a total noob in this and I'm sure I'll benefit a lot from this magnificient site! I'm sure it will be a while before I can contribute with anything substantial, so I try to help out on a non-robotic-skill-demanding here... :)  

A line laser can be made very easily from a regular one by sending the beam through a thin clear plastic/glass rod/disc. The thinner the rod/disc, the wider the beam angle. A rod with a 3-5 mm diameter should be appropriate. Hope this can be helpful, and that someday I can contribute with something more substantial...

Best, minimii

I intended this as a reply to GroG's bottom comment, and now I can't even remove it...