Junk 3D Laser Scanner

I thought to make this while I was staring at the back of a hard drive enclosure one summer during undergrad. At the time I was obsessed with making intricate parts on the laser cutter upstairs to fit into junk I found laying around.  The laser swings back and forth thanks to the brushless motor that original spun the disks in the drive. The webcam is angled up and down by a geared DC motor that I think I pulled out of a Robosapien toy.

Principle of Operation

An object to be scanned is placed in front of the rig. An Arduino and basic motor drivers control the camera and laser angles. The camera angle control is just for convenience - during a scan it stays still. Images are captured from the camera over USB and fed into a Python script that uses basic OpenCV image operations to find the vertical red line projected by the laser. With the current angle of the laser and the extracted line from the camera image it's possible to calculate a displacement map. The basic idea is that the line would appear to be straight if the laser were projecting its line of light onto a flat plane, so the horizontal deviation gives the Z displacement.