3D Scanning Fever
It will be a while before I can afford a 3d printer but I am already exploring what else I can do with it. I find it to be most useful in replacing broken parts around the house - I just lost count of the times when I wished I had a 3d printer to fix or fabricate things. But I'm pretty sure there's a lot more I can do with it. I want 3D printer so bad that I am even justifying its cost as being economical than shopping for Christmas presents. :)
Anyway, since I won't have it anytime soon, I started to explore 3D scanning. Being in a third world country, I tried looking for any do-it-yourself projects or open-source application associated to 3D scanning. To my surprise, not only did I learn that there are quite a few of them around, they have also been around for quite some time. I thought 3D scanning have just been invented recently. What rock have I been living under?
So, I got very excited and tried almost everything I can get my hands on. Among the 3D scanning solutions out there, here's what I've tried:
- Laser
- Structured light
- Photogrammetry or Structure from Motion
Again, the objective was to scan things in 3D with parts I already have lying around. Did I mention how excited I was? Well, let me tell you now that things didn't always work the way I thought it would. All the frustrations were mostly due to the quality of the materials I used but since I'm out of job right now, I want to spend as close to zero as possible so I really pushed things to the edge on this quest.
Laser scanning
What seemed to be a popular in the search engines was DAVID laser scanner. The trial version allows saving of a single scan. It was still a good thing to try since the version as of March 2014 also allowed for structured light (we'll get into this later).
To test DAVID's software, I needed a video or webcam (check!), a calibration board (I printed it out) and a line laser which I didn't have. I rummaged through some old stuff and found a pen with a laser pointer. It still worked but the battery was weak. The battery must have leaked since I couldn't open it so I just broke it open to get the guts out. Yes, that was how excited I was!
Oh, but I needed a line laser. I googled a bit and found out I can make it a line by getting it through a clear rod. I settled for a piece of clear glue stick. Far from perfect but it was the only thing I could find. Line laser - check!
DAVID laser scanner
First, the software - DAVID's software was very very easy to work with and will get you scanning fast. It has everything you need for the workflow. From scanning, mesh adjustment (it already gives you a mesh so you don't need to do that yourself) and merging the scans. It also gives you feedback when there's something wrong with the scanning process so you can correct it.
One advantage of the hand-held setup was that you can run the laser from different angles allowing you to cover a lot surface on just a single scan. However, I found it very difficult to merge scans using the built-in Shape Fusion tool. Even the contact pair selection method didn't give me a good merge since you can only select a pair of points to connect unlike Meshlab which asks for 4 pairs of points. The scans I ended up with didn't all match perfectly which is probably due to not having an accurate calibration. It says that the calibration board must be precisely 90 degrees. Mine was probably off a few degrees causing some skewing. Scan after scan after scan, my ghetto line laser just isn't giving me a nice clean, thin line. The sample video provided in their website gave me a clean mesh though.
The issues were probably due to the following so if you want to make this work well, here are some pointers:
- Use a real line laser - It would have given me a lot better mesh if I did have a real line laser
- Camera setting -You should be able to set your camera to show only the thin line of the laser. If you can't do this or do not know how to do it, expect a lot of frustrations. You will spend a lot of time cleaning up the noise in your scans and the time spent won't be worth it.
- Take time to build your calibration board carefully
I can see it working well with the right equipment but after a few days playing around with my ghetto setup, I gave up. I will get a line laser and test it again.
MakerScanner
The only open source scanner I found was
MakerScanner. This does not need calibration but the placement of the camera relative to the laser should be precise because it is hard coded in the software and it is part of the calculation of the 3D points.
Hans offered a better alternative so that you can set the distance between the laser and camera but there was no binary format so I wasn't able to try it.
The software is pretty simple and easy to use. The software gives you a colored point cloud. It doesn't have a built-in mesh viewer, mesh reconstruction or merging feature. Not a problem since you can do all that in
Meshlab. Again, I suffered from the same frustrations related to not having a real line laser so I'm setting it aside until I get a line laser. Based on my experience, I think MakerScanner right now is okay for single scans since clean-up and merging is a little too tedious. I'll try it out again when I get a line laser.
Structured Light Scanning
I happen to have a pocket projector with a busted power supply. I
remedied this by hooking it up directly to a 12V lead acid battery. I
was afraid I might fry my projector so I soldered a 2A glass fuse in-line. Projector - check!
This type of scanning makes use of different patters of lines to make out the shape of the object instead of a single line from a laser.
DAVID scanner
The same DAVID laser scanner software can also do structured light setup. The good thing about this setup was that you can remove the calibration board after the actual calibration so it doesn't get in the way while scanning. Also, a single scan took only a few seconds and that already includes the texture. What's not good about it was that scans seemed too shallow (see picture below) compared to laser scanning. It only captures what is almost directly facing the camera. This means you have to make more scans around the item and a lot of merging to do to complete the whole mesh. A high resolution projector and camera will of course improve the output.
Similar to my experience with the laser method, there was some skewing which I couldn't figure out why. Maybe it has to do with calibration. In addition, my success was prevented by a noisy line from the projector. The lines have jagged edges which translated into noisy meshes that was hard to clean up.
Overall, the workflow is a little faster compared to laser scanning but it also took a lot more scans.
Brown University - 3D Scanning Software
The only open-source structured light scanner I found was that of Brown University called
3D Scanning Software. It is very similar to DAVID and uses a checkerboard pattern to calibrate the camera. I just find it harder to calibrate for some reason. Another difference is that the 3D Scanning Software outputs a point cloud which you can manually convert to a mesh and stitch together using Meshlab. Still, it suffers from the problem of giving out shallow scans based on my experience.
Photogrammetry or Structure from Motion
Among the 3D scanning methods, I found this to be the easiest and enjoyable. It took very little effort on my part and all the heavy-lifting was done by the software so a modern PC, GPU, and lots of RAM will give the best experience. All I needed to do was take pictures of the subject from different angles, making sure there's a good overlap between the surfaces for the software to figure out how to put it together. The time it takes to process the files depends on the size of each picture, amount of detail in it, and how many pictures there are to be processed. Ironically, my experience suggests that the more detailed the pictures are, the faster the processing becomes.
The photogrammetry software I've tried were
Python Photogrammetry Toolbox (or PPT), which is console based, and
VisualSFM which offers a GUI but very similar to the former. I find VisualSFM faster in terms of processing. Here is an illustration of a typical workflow when reconstructing in VisualSFM:
 |
From pictures to sparse cloud to dense cloud |
Both PPT and VisualSFM gives you a dense cloud of points that you can convert into mesh using Meshlab. With less than 50 pictures, I was able to get a detailed reconstruction of the gazelle which was only around 6 centimeters long.
To get a clean output, some commercial software like Agisoft's Photoscan allow you to mask the objects in the pictures to ignore the background. You can also use an image editor to cut out the background before you feed them into the software but that will take time so I tried feeding the same set of raw pictures to both VisualSFM and Photoscan to see how each of them will handle the noise.
 |
Raw input picture |
With the camera fixed, the input pictures were taken with the gazelle on top of a tripod, using it as a turntable. The background was not completely covered from side to side as you can see from the picture. Here is a side-by-side comparison of the dense cloud output from both software:
 |
Left: VisualSFM/ Right: Photoscan |
As you can see, VisualSFM pretty much guessed where the edge of the wall was so it was easier to clean up because the points are away from the subject. Photoscan on the other hand, had the points very close to the subject itself making it very hard to remove. Something for Photoscan users to remember - mask out the background first before feeding in the pictures.
The following are some key points for an efficient reconstruction:
- Uniform light - If the object is small, you can probably use a tent softbox. Avoid any shadows. If the object is big, take pictures out on a cloudy day.
- Sharp pictures - If using a DSLR, set the f-stop as big as it will allow you. Also avoid motion blur so set shutter speed to the fastest your camera allows that will still give you a bright picture. If scanning a person, make them hold the pose as steady as possible.
- Overlap - Make sure the outer edges of the pictures overlap that of another picture so that the software can map them well. If using a turntable, make sure the background is either completely black or white and does not have features on it that will confuse the software. Otherwise, you will have a lot of stray points that you have to clean up
- Cover the complete area - Feeding more pictures won't necessarily give you a better reconstruction. It's better to give only enough pictures to cover the surface area of the subject being scanned
Overall, I had the most fun reconstructing a 3D model using photogrammetry than any other methods I've tried. Given that you won't be able to get away with some cleaning up of stray vertices (which applies to all methods), it was still the simplest, easiest, and gives the best looking output. I'm not saying this method is the panacea of 3D scanning. Reconstructing models like Yoshi didn't work well since the surface is pretty flat and not enough features can be extracted from it. I'm pretty sure there's a space for all of these 3D scanning methods depending on one's budget and application. Here's a breakdown of how I see each method being more effective than the others.
3D Scanning Methods Compared
- Laser
- Best if accuracy is needed and scanning big, static items and spaces
- Not safe for face scans without closing eyes or wearing eye protection
- Structured light
- Best for use on simple, shallow, solid, opaque and plain items that do not have enough
features or marks on it. If this is your only option, find a way to
coat the item to be scanned with a matte finish. Safe for scanning faces.
- Not good for dark colored, translucent, reflective and very deep items
- Photogrammetry
- Best if subject has a lot of features or texture
- Very dependent on the quality of the pictures like motion blur, sharpness, depth of field, exposure, lighting, etc.
Now, I think I'm enjoying my son's toys more than he does :)
 |
Pictures used to reconstruct this came from frames of a video |
 |
Reconstructed using only 36 images that are about 7 megapixels each |