Home Made 3D Laser Scanner.
Several people have reported success at building cheap devices to scan a real-world 3D object into the computer. However, all seem to be a bit light on the precise details of how to do it.
We'll try to correct that.
You may find other ways to obtain these parts - but here is what we used:
- A cheap laser pointer.
- A reasonably high quality lens to spread the laser light from a point into a line.
- A digital camera or video camera capable of recording 10 seconds of video at around 640x480 resolution. Higher resolutions are great - lower resolutions are pretty marginal.
- Some kind of turntable to rotate the objects you wish to scan at a nice, slow, constant speed.
- Some way to clamp the laser and camera into position and to adjust them carefully.
- A dark place to set it all up.
- Software to turn the resulting video into a 3D model.
You can find cheap red laser pointer everywhere - the kind we used seems to be vvery common. It comes with a bunch of interchangeable lenses that produce arrows, circles, dollar signs, etc. Remove the lens it comes with - you don't need it.
I paid $3.20 for mine in Fry's.
'Line Generator' Lens.
This is by far the hardest part to obtain. You need to take the point of
light that the laser pointer generates and spread it out into a 'fan' of
laser light which subtends at least 45 degrees. In theory, a cylindrical
or semi-cylindrical lens will do the job - but we found it very hard to find one that produced a nice even line at a wide enough angle.
An initial suggestion was to use the stem of a wine glass. After testing
half a dozen different kinds of glass from our kitchen, the best we found
produced a very fat and uneven line.
Another possibility is to dispense with the laser pointer and use one of
those 'Laser Levels' you find in DIY stores - decent ones are pricey ($100)
- cheap ones ($20) produce very uneven lines. Both kinds generate very short
lines - which means that you either have to limit yourself to scanning very small objects - or you have to put the laser a LONG way from the object you are scanning (which results in an even more blurry line).
We also tried using a semi-cylindrical lens found in many bookstores to allow people to read a whole line of text under magnification. This produced a very uneven and blurry line.
In the end, a professional fresnel lens was purchased from eBay - it produces an exceptionally sharp line with about a 70 degree angle. Perfect!
Here are some of the failures:
(Top left: Wine glass stem mounted in a Lego mount,
Top right: Cheap laser level,
Bottom: Reading magnifier.)
We used a SONY MegaPixel Handycam. It writes video to a small DVD which I
could read directly on my computer without having to dismount the camera
and carry it over to the PC to read out the data. It generates 700x480
One handy feature is a small infrared remote contoller that allows you to
start and stop recording without touching the camera (and perhaps jogging
it out of alignment).
Since we have a small mountain of Lego Mindstorms, this was a natural solution:
Penguin is optional!
Lots of reduction gears to make things S-L-O-W.
A Lego train controller allows easily variable
speed control. (Note also the remote control for the camera)
Mounting the laser and its lens into a Lego mount was a snap. I was also able
to rig it up with a Lego part pressing down on it's On-switch to keep it
on throughout the scan.
The laser needs to be aimed at the center of the
turntable - so I built a geared adjustment rig. You could skip that step.
The camera also needs to be held firmly in place and aimed so that the center of the viewfinder lines up with the center of the turntable.
A Dark Place to Play.
We've been scanning at night with all the lights off. Rigging a simple light-proof tent of black velvet would be better.
This turns out to be fairly easy - but it could use some automation and streamlining:
- I used the OpenSourced 'mplayer' and 'mencoder' software under Linux to rip the DVD into a bazillion individual frames.
- Next, I bring up the 'xview' program and tell it to generate thumbnails for
all of the images. Scrolling through the list of thumnails lets you find
the a set of frames that represents one exact 360 degree rotation of the turntable. (There really needs to be an automated way to do that - but life is short)
- Finally, a program that I wrote examines each frame in turn to find the center
of the brightest group of pixels on each scanline. This is a good
approximation to the center of the laser line.
You can then calculate the fraction of a screen-width by which our 3D
object deflected the laser beam. Since we know the field of view angle
of the camera lens - so we know the angle between the point where the
laser struck the 3D object and the center of the screen (which is pointing
at the center of the turntable).
- Since you also know the angle between the laser and the camera and
the distance of the camera from the center of the turntable, you know two
angles and one side of a triangle. From there, it's easy to use high
school geometry to find the 2D coordinate of the point.
- A similar approach in the vertical dimension gives you the third
dimension for the point.
- Since you have 480 scanlines in each of maybe a thousand frames, you
now have half a million 3D points that are (hopefully) lying on the surface
of the 3D object.
- I averaged multiple points together to reduce the inevitable
noise from the approximations in the system - and after filtering,
reduced it down to a few thousand 3D points.
- Skinning these with triangles produces the final image which can
be written out in the 3D model file format of your choice.
Putting it all Together.
As you set the system up, you'll need to make a few measurements.
It's possible to record a second video of the object rotating in front of the camera - this time with the laser turned off and the room lights on. By running this second set of data through software that extracts the colour of the pixel at every place where the laser appeared in the original sequence, we can extract a texture that can be applied to the surface of the model.
Making the texture line up exactly with the 3D image may be a little tricky if your turntable doesn't run at a pretty consistant speed.