How to scan objects into 3D using structured light?

How does this work?

Structured light is a method of 3D scanning where we project a known pattern onto an unknown surface and by analyzing the deformation (warping) of the known pattern we can mathematically reconstruct the surface virtually. Note: this is a 2.5D scanner, meaning that it scans surfaces, but in order to get a real 3D point cloud of an object you have to construct a rotating stage and scan the object from multiple angles and than "stitch" the scans together.

What you will need

Getting set up

First let's download the softwares you will need. The following program was written by a bunch of different people, the repository can be found here with a lot of additional information about the technique:

Google Code Repo - Structured Light

Today we will be using the Three Phase Processing sketch. Download it from here! This sketch is expecting three images corresponding to three phases as you might have guessed from the name. A phase means here that you project first a series of black and white lines, than you take a picture. Than you project the same lines but you shit them down with one-third of the spacing between two lines. The three images to project can be downloaded here.

So from the left to the right you can see how the lines start to move down. You really have to take care when feeding the decoder with your images, because you want to be sure on passing the three phases in the right order!

If you have a Canon Camera you can download this little app written by Tony deVincenzi that automates the whole [project phase #1 - take a picture - project phase #2 - take a picture - project phase #3 - take a picture] process, with automated camera control. It is compiled with OpenFrameWorks if you have problems contact me. If you don't have a Canon camera don't worry, you can get perfect scans if you are careful.

Download automated Canon control! [~60MB]

Setup your equipment

Probably one of the most important part follows: how to arrange 3 things, namely the camera, the projector and the object to scan. This part is experimental and up to you to figure it out. For me these settings yield a nice scan:

Yes I used Powerpoint, I am sorry. :)


Once you have set up everything it's time to scan. It's easy.

Step #1: project Phase 1, take a picture of your object.

Step #2: project Phase 2, take a picture of your object. IMPORTANT: throughout all your images try to maintain the same white balance, focus, etc.

Step #3: project Phase 3, take a picture of your object.

That's it! Below are some pics of the raw captures. We got nice point clouds with these!

Reconstructing some 3D from the images

Now we are going to reconstruct the 2.5D that we can get from the images. Open Processing and load the TreePhases sketch. In the folder of ThreePhases you will find a folder named img. Now take the three images you took and copy them into this folder. Take extra care now and RENAME them phase1.jpg | phase2.jpg | phase3.jpg in order of shooting them! DOUBLE CHECK the order!

Now run the sketch by clicking the play button in Processing. After couple of seconds of calculations you will see a point cloud. Some times it's pretty by default, sometimes you have to tweak your cloud. There are two controls you should be concerned about. Z skew and Z scale. Z skew manipulates axes warping, while Z scale scales on the Z axis. First use Z skew until you achieve some 3D from your object, than use Z scale. If you got lost just rerun the application, you will start from default again. If it doesn't resemble anything like your object here is an incomplete list of what you can do:


Last week we had a nice workshop, so here are some of the scans that turned out pretty well.

Exporting your scan

Once you feel comfortable with your scan here is how you can get your favorite STL, DXF, etc. format. First on the control box where the tweak controls are press the export mesh button. This will place a PLY file in the source directory of the TreePhase folder. This can be read by the crossplatform editor called Meshlab:

Open the file in MeshLab, play around with it and export it to STL, DXF or ...


To be cont. This tutorial has to evolve. It can do so if you contact me and tell me if you run into a problem and that the tutorial did not cover.
You can reach me: dlakatos {et] mit {dot] edu, my name is David Lakatos.

Last updated 2010-October-31