-
Making a 3D Scanning Dome - Part 2
01/31/2018 at 20:46 • 0 commentsMaking a 3D Scanning Dome - Part 2
1st of February 2018
In my first post I talked about some of the structural elements of the dome and cameras I chose to do the scanning. From here we move on to preparing the dome for scanning by improving certain elements such as a turntable and a skin.
Skinning a dome
There are two difficult steps in building a geodesic dome: the hubs and the skin. It's quite difficult to make a skin that fits seamlessly over a frame. There are various designs, and quite a few are terrible! I've never really seen a good, amateur attempt at creating a good surface on a dome. However, I thought I'd give it a try.
Skinning a dome is important because reconstruction software tends to fail if the background is complex. This is doubly so if you are using a turntable (which is the general way of scanning small objects). So we need to mask out the background. We can do that all manually, or we can make things easier on ourselves by using a skin. Another effect of the skin is to soften the harsh LED lighting, converting the spots to something a little more diffuse.
I decided to use 3 levels of cone which approximates a sphere. The idea is to stitch these together, suspend the skin from the inside of the dome and poke the cameras through at each nodal point. To start with, one needs to do a little maths, figuring out how wide each cone needs to be, then unrolling each cone from 3D to 2D, printing off the final pattern then cutting the material.
With the math worked out, I write all the equations into python and end up with a set of values I can use to create a sketch. I tend to use either inkscape or librecad when I'm coming up with cutting patterns (lasers or material or whatever). Librecad (in the case) takes a little time to get used to, but it works. I printed out the pattern at a FedEx office. They have large format printers that are reasonably priced. With the pattern cut, you can pin it onto your material of choice. I bought a roll of camera flash diffuser fabric from eBay. Use a very good pair of scissors! Anyone who sews will know what I mean! :D
With the material cut, it's time to sew. It's worth making out where the nodal points will be, before we start sewing, just so we know where we need to add eyelets. I punch a hole with a hole punch, and use brass eyelets with a special tool that crimps the eyelets in place.
The skin is suspended from the inside of the dome using ribbon, which is hand sewn at various points around the skin. Pulling these taught and tying them off on the struts seems to work great.
I'm reasonably pleased with the result. It's still possible to see the individual LEDs through the mesh, however the background is removed enough to make automatic masking possible, or at least make the manual mode much easier.
Modifying the cameras
At first, I was using cable-ties in order to get the cameras attached. Sadly, this is not ideal. The cameras are mounted too far forward and in the wrong place. What is the best thing to do? Well, take them apart and use a load of Gorilla Glue!
It turns out that the C910 can be taken apart reasonably easily. Once the clamp and outer casing is removed, there appears to be a metal plate at the back. This is perfect for mounting a nylon M6 bolt on the back. Using Gorilla glue, I can get a reasonably good join. It's important to keep an eye on the bolt as it dries; we want it to be perfectly straight. This would lead to problems later on with adjusting the view from each camera.
The need for turntables
With the cameras in place, I decided to try a test scan. The results were somewhat disappointing. The final mesh could not be created. It turns out we need many, many more cameras than 8 or so. With that in mind I decided I should try a turn-table.
Looking on ebay, it is possible to get hold of turntables for cakes, jewellery and other things you might want to display in a shop window. Some are really cheap, others are surprisingly expensive. I bought one for around $60 or so. It's reasonably flat (at least for the price-point). I wanted it to be as low as possible so as to not limit the size of the objects we can scale.
With a turntable, we can use many few cameras; I got away with just 3 C910 cameras mounted on the dome.
The key advantage of getting the lighting right is that you get a consistent surface reconstruction that can then be properly lit inside whatever program you write. You want to remove as many shadows as possible. It's easy to see why the professionals spend a lot of money on fancy light-boxes to get every part of the object evenly lit.
Going further
In our next post I'll talk about ways we can improve the scanning, what went wrong with the design, which bits can be improved (and have been improved) and where we go from here.
-
Part 1 - Initial Design and Build
01/07/2018 at 19:42 • 0 commentsMaking a 3D scanner is a tricky project. I learned a lot about the algorithms involved when I built a similar scanner for the University of Leeds sometime ago. Since that time, there have been many advances in the technology and now, one can buy a cheap, laser line scanner for not a lot of money. They all have their problems though. Some are low resolution, others don't capture the surface textures properly. One thing that is key though - you want to control the light. A good friend of mine Dr Hannah Dee over at Aberystwyth University, showed me a project she was working on involving a dome with controllable lights. The theory is, if you want to capture the texture of an object, you need to sample how it responds to different lighting conditions in order to recreate all these bump maps, normal maps, albedo maps etc. I figured this was a good place to start. My initial design didn't include a dome, but who doesn't love a Dome right?
The basic design
I have a few objects in mind that I want to try and capture, so the dome has to be big enough to accommodate these objects. I made a rough estimate of the size the dome would need to be. I've still not found calculator and hub design that I trust I have to say! Not sure why, but although it's easy enough to generate the required strut lengths, the problems with geodesic domes all come down to the hub connectors. In the end, I decided to modify a design a found in thingiverse. As this design uses the wrong units, I converted it to good and correct metric units, using the program Design Spark Mechanical. This program is a little easier for me than Autodesk or solidworks, if I'm just doing minor corrections. I altered the hubs so they would accept 5mm thick acrylic.
Thanks to another friend, Dr Julie Freeman I managed to get the hubs 3D printed (using a proper 3D printer and not a glue-gun on rails!) and laser cut the struts. I added holes along the struts so that I could bolt on any things I'd forgotten down the line. The prints and cuts came out beautifully I think!
Putting it together
Despite how good the printed parts were, issues with the design did begin to creep in. The support material in the 3D printer is a waxy-like substance that you need to clean off with a special pressure washer. This is loads of fun I have to say, but the process is not perfect. There are lots of annoying left-over residues inside the slots for the struts. This means the fit was not always perfect and in some cases, the thin 5x5mm strut end would snap. I think a better locking mechanism will be needed next time, as oppose to a push/snap fit one. Top tip people - always make spares!
Cameras
The first version of the dome was inspired by my previous attempts at a scanner. I wondered if it was possible to cover the dome in cheap, yet high resolution webcameras, instead of using a single SLR or equivalent? This would cut down on the time to take all the snaps required. My camera of choice is the Logitech C910. The reason for this is that I'd had a few lying around already from the previous gig and so buying a few more wouldn't increase the costs too much. The resolution is acceptable and they can be controlled via UVC under Linux.
This latter point is quite useful! It's very important to be able to programmatically control the white-balance, resolution and more critically, the focus. You can do all that with a variety of programs, my favourite being GUVCView. This program can be called from the command line with a list of settings, held in an XML file. So once you've played with the settings you want, you can save them out and use them again really easily.
This page has a good review of the field of view from both cameras. I can summarise the basic stats as follows:
Max res 2592 x 1944 Focus distances in cm with the non-continuous steps: 255 / 3.5 238 / 3.8 221 / 4 204 / 4.3 187 / 5.3 170 / 6.4 153 / 8 136 / 10.5 119 / 15 102 / 25 85 / 40 68 / 51 Roughly a 3mm aperture. Focal length is 4.3mm. This would give an f value of 1.43 (1.4 seems about right I guess). Connection Type Corded USB USB Type High Speed USB 2.0 USB VID_PID VID_046D&PID_0821 UVC Support Yes Microphone Yes Microphone Type Stereo Lens and Sensor Type Glass Focus Type Auto Optical Resolution 5MP True Diagonal Field of View (FOV) 83° Focal Length 4.3 mm Image Capture (4:3 SD) 640x480, 1.2 MP, 5.0 MP, 10 MP Image Capture (16:9 W) 360p, 480p, 720p, 1080p Video Capture (4:3 SD) 320x240, 640x480, 1600x1200 2MP Video Capture (16:9 W) 360p, 480p, 720p, 1080p Frame Rate (max) 30fps @ 640x480 Right Light Right Light 2 Video Effects (VFX) N/A Buttons N/A Indicator Lights (LED) Activity/Power Privacy Shade Yes (Software) Tripod Mounting Option No Universal Clip Adjustability (range) 0° to 180° (Adjustable) Cable Length 5 Feet or 1.5 Meters
The biggest problem with the C910 is it's mounting. It's a real pain to do anything with unless you are putting it at the top of a monitor. In my initial tests, I just cable-tied a few of them to the support struts.
You need quite a few USB controllers to take care of 8 of these cameras (I had managed to buy 8 - the same number I used in my previous scanner). In the end, rather than buy a couple of controller cards, I decided to get some cheap USB powered hubs and drive the cameras individually, taking a single snap-shot each.
Rather than post the code here, you can view it on github in the scanner directory. I've included a lot of older code in there, which I will need to filter out but the majority of it works fine. One thing I noticed is that when taking a screenshot, one needs to access the camera a few times because the focus, and indeed the white-balance, isn't immediately set correctly. If you look further down int the main function you'll see what I mean. This program outputs raw bitmaps, as it's advisable to avoid compression artefacts when creating 3D scans from images.
The LEDs
Again, scavenging from another project, I had a load of TM1809 LED strips lying around. I won't lie, these things are mostly terrible! I find them to be just a little too flakey. Sometimes, they'll stop working or one LED will be the wrong colour, or something else goes wrong. However, I don't quite need perfect LEDs for this project, just some illumination.
Each strip of 3 LEDs fits quite nicely on a single strut of the dome. This means cutting, soldering and attaching around 50 such strips! Only thing to do is to brew up several cups of tea and get cracking!
Controlling the lights requires some sort of micro-controller. I've used the Arduino in the past, with the FastLed library so I figured I'd just use that again
The next steps
With the dome all setup and the LEDs and cameras in place, I decided to take a few initial tests with the camera. Using agisoft photoscan I took several photos around a couple of test objects. However, I the results weren't all that great. The main problem, I was told, was to do with the busy background. It was suggested to me that I try and mask out the background, possibly using a combination of the manual masking modes in the program and an actual diffuser screen inside the dome. In the next post, I'll describe how I built such a screen and where I went next.