How to build a 3D scanner with a webcam and a hand-held laser

Did you know that you can make an accurate 3D scanner without whizzing robot arms, expensive lasers, highly priced software and a doctorate in several arcane sciences?

As it turns out, if you simply outsource that last bit to the scientists; everything else is relatively cheap and easy to obtain.

That's how the DAVID Laser Scanner came into existence. It's the result of work carried out by some academics who decided that there must be a way to grab depth and contour information with a single camera and some simple references.

The software only needs a pair of these references to copy a real object into a computer representation. A 90-degree scanning enclosure and a line laser do the hard work at your end. Both are known quantities, which means that by shining the laser at the enclosure, we see a bright 'V' of light that precisely describes the plane of the laser.

If we place an object in the scanning enclosure and point the same laser at it, we will still have the same references for the plane of the laser – but now the laser will also describe a contour of the object. Then, by taking the known references, you can interpolate that contour into a set of points – or vertices – in 3D space.

The concept is simple, but it relies entirely on the accuracy of the enclosure and the proper calibration of the camera image.

Unzipping DAVID

First, download the free version of DAVID. There's no installer required to activate the package – you just unzip it to a folder on your computer. You'll also need to make sure that your PC is updated to at least version 2.0 of .NET. This should already be present if you use automatic updates, but you can install it from Windows Update manually or download the distributable version for your edition of Windows directly from microsoft.com if required.

To run DAVID, you need to open the folder that you extracted the application from and run 'Start_David.bat' or 'David- Laserscanner.exe'. The batch file checks that you have .NET 2.0 installed, so if you know what you're doing you can run the executable directly.

You can have a play with the software if you grab the 'AngelScan.zip' file from the Downloads section on the DAVID site. Unzip the file and drop the enclosed AVI files onto your computer. Open DAVID and work your way through to the Calibration page. Select 'Video Grabber' in section one and then find the 'angel_calib_wmv.avi' file in the Open dialog that pops up. This opens up the calibration video. Click 'Calibrate Camera' and then click 'Next'.

Now click the 'Camera' button in section one and open the 'angel_scan-wmv.avi' file to load the scanning video. The example video should start playing. Click the 'Start' button in section one and DAVID will start building the 3D model. You'll notice that the gradients between the colours in the sample model are well defined, with relatively little graphical noise or holes.

Next, take a look at the speed that the laser is scanning at and observe how the full data is collected in just a couple of passes. Click 'Show 3D' in section three and you'll see the scan in 3D. That's the kind of quality you should be looking for when you start scanning your own objects. But before you can do that, you need to build your own enclosure.

Building the enclosure

The accuracy of your enclosure is the most important part of the scanning system. The sides need to be free of distortion, and set at exactly 90 degrees. If you aren't able to get the correct angle, then the calibration will be incorrect and the scanned model distorted.