2D Room Mapping With A Laser And A Webcam

[Shane Ormonde] recently learned how to measure distance using just a webcam, a laser, and everyone’s favorite math — trigonometry. Since then he’s thrown the device onto a stepper motor, and now has a clever 2D room mapping machine.

He learned how to create the webcam laser range finder from [Todd Danko], a project we featured 7 years ago! It’s a pretty simple concept. The camera and laser are placed parallel to each other at a known distance, axis-to-axis. On the computer, a python script (using the OpenCV library) searches the image for the brightest point (the laser). The closer the brightest point is to the center of the image, the farther the object. Counting pixels from the center of the image to the laser point allows you to calculate an angle, which can then be used to calculate the distance to the object — of course, this needs to be calibrated to be at all accurate. [Shane] does a great job explaining all of this in one of his past posts, building the webcam laser rangefinder.

From there it was just a matter of slapping the rangefinder onto a stepper motor, driving it with a small PIC, and running the calculations on the fly! His results are fairly impressive.

20 thoughts on “2D Room Mapping With A Laser And A Webcam

  1. Try replacing the laser pointer optics with line optics (or use a cheap laser level tool from economy hardware store). This will make a vertical line instead of a dot.
    Now you can use your code to check all the pixels in an entire vertical stripe instead of a single dot. and get a lot more vertical res.

    For fun and entertainment – the IR filter on your webcam could be removed but you could add a green laser instead – also shot through same optics (or directly adjacent to red line, or in same position but switched on and off on alternate frame times).
    Or a blue laser or whatever – the point being that surfaces that don’t reflect red well might reflect another colour better.

    Great work. and in Python too. Yay Python !

    1. There’s a bunch of n-Copters and wheeled vehicles that do this task. Sebastian Thrun made an ATV that maps derelict mines. the Simultaneous Location And Mapping(SLAM) problem has quite a following and decent funding as of late.

  2. I have always had this idea of some type of system that simply senses its surroundings. Have you ever noticed that you can feel when something is behind you? Even things you can’t see, you have a sense (as inaccurate as it is) of your surroundings. If you walk in the dark, you can sense that you are coming upon a wall. Or when someone is standing behind you suddenly.

    The effect I think is changes in air pressure. Like the Archimede’s principle. Air is a fluid, and anything within it will displace it which creates a directional force. I believe we can sense this pressure change on our skin.

    I haven’t quite figured out how to build something like this, but in my head I forsee something similar to an arrangement of speakers used as microphones. Obviously that should be able to sense pressure changes due to a disturbance in the fluid air, but if the measurement device is stationary and the objects in the room are stationary, it seems like it would measure nothing.

    Don’t laugh, but I’ve always named it acoustical mass displacement sensing.

    Any thoughts on this?

    1. Incomplete thought. In order to sense things, one of the parts in the system will have to move. I wonder if simply vibrating the sensing instrument (and then filtering that vibration out) would be enough.

  3. I’d like to point out another cool hack in this picture: The use of zip ties and metal scrap to prevent a pair of helping hands from tipping over. Why didn’t I think of that?

Leave a Reply to hugowesselingCancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.