Building a Homemade Laser Line Scanner (CS6998, Spring '01)

May 1, 2001

Team: "Have Screwdriver Will Travel"


The goal of this project is to build a low-cost laser line scanner out of off-the-shelf parts and stuff I find around the house and to use it to construct a reasonable point-cloud scan of a recognizable object. From the point cloud, existing software can be used to create surfaces, and hopefully solid models as well (undetermined).



The cost and performance of the system was determined partly by the hardware available. I chose the Nikon camera because I already owned it, thus reducing the entire cost to under $100. For the laser, I decided that since I would be doing image processing in software anyway, it would be far easier and more cost-effective to correct for the effects of a low-quality laser in software than by trying to get my hands on a proper research-quality laser. For image acquisition in the computer, I used my existing video card which also has video inputs. In the end, I spent the most money on parts I didn't actually use, such as mounting brackets and other junk from the hardware store, and a small batch of unuseable laser diodes (needed laser diode modules) from digikey.


The software is divided into three logical pieces.

Scanner driver pieces (detectbutton, timerotation, beep)
There are two programs that talk to the scanner direcly.
Detectbutton detects the scan-control button on the scanner box. It simply waits for the signal on the serial control line to go high.
Timerotation times the speed of the turntable over the serial port by watching another control line.
Scan-acquisition scripts (takescan_*.pl)
These are perl scripts which call third-party image-acquisition software for whatever video hardware is being used. This could be ATI, SANE, or V4L2. They prepare the data to be processed and deliver the time-of-scan data necessary to do the per-image data rotation.
Scan-processing program (procscan4)
This is the C program that does most of the work. It reads in a set of configuration files which define the parameters for the camera, scanning geometry, and the individual scan and then processes all the grayscale images one-by-one. Each image is processed using a simple Mean Pulse Analysis without regard for the other images in the set:
  1. Find the center of the laser for each scanline in image coordinates
  2. Cast rays though each pixel and intersect them with the known position of the laser plane using standard vector math techniques to discover their 3D locations in camera coordinates
  3. Transform each point into world coordinates using the camera calibration matrix and rotate them into the correct position based on the angular rotation of the frame.
  4. Output the points in an NxM grid, including 0-data points to preserve the rectilinear grid structure of the data for later meshing.

Some third-party software was used to edit the point clouds and create the surfaces on the data page. The Alias suite comes with a tool called EvalView which is useful for editing point clouds, but does't preserve the rectilinear structure of the data. This is really really really annoying. Fortunately, there is a cool piece of software (which mostly works) called Alvis (Alpha Shapes Visualizer) from NCSA which will create surfaces from unstructured point data. The surfaces on the data page were created with this tool. Unfortunately, as with many research projects, this code is no longer supported and occasionally fails under Linux. The source code is not available for the recent versions.

Technical Details


The scanning platform is built from a piece of scrap wood from the hardware store into which I mounted two roughly vertical pieces of 1/4" threaded rod 30cm apart. Several pieces of angle-iron on each armature serve to support the camera and laser assembly on their respective mounts. The laser is strapped to a T-shaped piece of wood onto which the cylyndrical lens is strapped (laser and lens mounting is achieved via innovative duct-tape restraints, the details of which will be discussed in a later journal article). Radial lines were inscribed on the wood base around the axis of the laser for measuring laser angle, but these were later discovered to be both inaccurate and unnecessary. The short axis of the platform is oriented towards the center of the axis of rotation of the turntable.


The laser is a basic red single-spot laser pointer from an online source (it is not legal to sell laser pointers in NYC because apparently violent criminals strap them to their pistols). The laser is powered by two 1.5v AAA batteries which are normally housed in the barrel of the device. I replaced the batteries with an internal structure which makes the necessary electrical contacts and has wires running out to an RCA plug so that power can easily be moved, replaced, or controlled externally. The spot produced by the laser is not perfectly round - it is actually slightly rectangular in shape. I orient the long axis of the spot vertically so that the cylindrical lens stretches the laser along the long axis of the spot, producing a taller, thinner beam. Fortunately, the non-gaussian shape of the laser is actually a bonus in this setup, and the effect of the lens allows the stripe to be analyzed as a gausian in each dimension separately, if desired.


The camera is a midrange consumer digital camera (~$425 including NiMH rechargeables, charger, and additional 16MB compact-flash card in the fall of 2000) which has a standard 1/4" tripod mounting sleeve in the bottom. To optimize image coverage and vertical resolution, the camera is mounted in a portrait orientation. The change in orientation is unwrapped in software automatically from the calibration output. Still images on the compact flash card can be transferred to the computer via serial cable, but this camera conveniently supports a dumb-operation mode where it just outputs NTSC 640x480 full-motion video on an RCA jack. This runs directly to the image acquisition hardware on the computer.


I built a custom electrics box into a plastic floppy disk case which is screwed to the wooden scanning platform. It has a short-circuit turntable timing line to time turntable rotations. Outputs are 3v from two internal AAA bateries to power the laser, and a 9pin serial port to the computer. The box has a power switch which turns on the laser and connects the turntable detection line to the serial port. A temporary switch tells the computer to take a scan images. All communication takes place over the serial port control lines.


The turntable is a slightly modified Garraud model from the Salvation Army. The multi-disc armature and center post have been removed. The audio pickup has been outfitted with a spring-loaded temporary switch which is positioned near the edge of the table within range of a longish extension which toggles the switch for several centimeters of each rotation for the purposes of timing the rotation speed. It turrns out that under the hardware and scanning condition constraints the turntable actually moves too fast, so I now manually position the turntable in 5-degree increments (inscribed on a positioning overlay intersected w/ the laser plane) for slow low-resolution, but more accurate scans. This is currently the bottleneck to further system development.

Platform Calibration:

Camera/Laser calibration is performed by running Tsai's calibration code against a set of manually selected correspondances in a full-light, no-object test image of the scanning platform with a calibration checkerboard overlay. Since Tsai's coplaner code assumes an X/Y plane, the y/z input data coordinates must be swapped. Tsai's algorithm takes a set of basic camera parameters, including CCD pixel dimensions and resolution. The output is the XYZ rotation matrix and translation vector of the camera relative to the calibration plane, along with the focal length of the camera in a pinhole model. These output parameters are entered into the appropriate scan-processing config files.

The calibration of the laser plane is achieved by aligning the x-axis of the calibration checkerboard with the projected laser line. The resulting Y-rotation of the camera is the angular difference between the camera and the laser. This is picked out in software. This little trick VASTLY simplified the scanning platform setup as you don't need to measure anything.

Scanning Process:

  1. Turn on the scanner and Invoke the scan-acquisition script, specifying either the number of frames or the scanning time in seconds, depending on the hardware/software configuration.
  2. The object is placed on the scanning table w/ the laser on for a single full-color sanity-check image. Push the scan button once, wait for 3 beeps.
    [sanity photo]
  3. Remove the object and place the beam-calibration post/panel on the axis of roation to take a clean image of the entire laser beam. Turn the lights off. Push the scan button once, wait for 2 beeps.
    [laser calib color]
    [laser calib grayscale]
    [laser calib segmented]
  4. Remove the beam-calibration post and position the object to be scanned on the turntable surface. With the lights off, press the scanning button one more time. For an automatic scan, the computer/scanner will measure the rotational speed of the turntable (which must be on at this point) and then take a series of images. For a manual scan, the scan button must be pressed to take each image (wait for the beep) and the turntable manually rotated the appropriate number of degrees. I use a 5-degree radial scanning overlay for the manual scans.
    [sample gray scan image]
  5. The output images are converted to PGM format automatically, if necessary. The scan time and RPM parameters are appended to the default scan config file (60sec and 1rpm for a manual scan) and then the beam-calibration image is displayed so you can add the start and stop coordinates of the beam on the calibration post for the purposes of segmenting the beam to characterize it. This bit is only partially used right now.
  6. Run the scan-image post-processing software on the resulting data to output a point cloud.

Future Work