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.


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...

What i like about your idea is it would be possible (because of the camera optics) to zoom in for better pickup of the laser, webcams and wiimotes have fixed lens's.

Maybe this would give a better range - just speculating .......

That is an awsome idea! Wow. Must have a camera that by MCU control can zoom in.


Distance = Long away.


Analysing: That extremely far away object (20 meters) is a little closer than that one! (by 2 centimeter)


Pure Arnold S!

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 :)

Congratulations you've re-invented the Sharp IR sensor :P

The actual sensor in a sharp IR sensor is just like a camera except only a single line. The circuit then looks for the bright point along the line.

By using triginometry you should be able to calculate the distance.