Instructables

Multiple Raspberry PI 3D Scanner

FeaturedContest WinnerContest Winner
Picture of Multiple Raspberry PI 3D Scanner
3dscansetup.jpg
britt_shapeways.jpg

Hi,
I am a big Arduino and Raspberry PI fan and also love 3D printing. I wanted to be able to make a 3d model of my kids and started investigating how to build a 3d scanner. I found a lot of solutions out there, but the problem with most of them is that the subject would have to sit still for a while... well I think it would be easier for me to invent a spaceship that can fly to mars then inventing a solution for my 2-year old son to sit still :-( So none of those solutions where going to work.

I knew I had to come up with a way to instantly take many images at the same time. So I first started to research what cheap digital cameras exists. If I could find a cheap model, I probably could make an automated trigger system using arduinos. But then I would have all the images on many separate SD cards and I was not able to find a cheap good digital camera.

Then I noticed the Raspberry PI and PI camera combination. A "fairly" affordable module, that already is ethernet connected, so I could do the triggering of the cameras using the network and an easy way to download all the images to a centralized place. So my Project (and investment) started.

I bought for this project:
- 40 Raspberry Pies for this project and 40 PI cameras.
- 40 8Gb SD cards
- 1 single 60A 5v power supply to power all the raspberry Pies
- Led Strips and a powerful 12v power supply to power them on

As I am an impatient person I did not build the whole setup at once, I started of with 12 cameras, and was already seriously impressed with the results. So you DO NOT need 40 cameras, especially not if you just want to catch just the front of a persons face.

Here a result output:

UPDATE:
I have included a photo of Britt (the model in the video) being printed in full color by shapeways.

UPDATE2:

I finally was able to make a scan of my little son Hugo (2years old). It was made using 47 Raspberries and using my new softboxes with permanent lights. This allows me to shoot the images with no shadow. Can't wait to receive the printed model from shapeways :-)

 
Remove these adsRemove these ads by Signing Up

Step 1: Setting up the hardware

Picture of Setting up the hardware
testsetup-300x225.jpg
photo.JPG
photo (1).JPG
photo (3).JPG
So I first needed a rig to hold the Raspberry Pies. I initially did some testing with a big round circle I made out of wood, but this was really impractical to work with and hard to walk in and out of. So after some testing, I went with an "individual pole" design. Most programs that turn images into a 3D model need the images to be shoot from different angles. So I settled for each pole to hold 3 Raspberry Pies cameras.

I made the poles out of fairly cheap multiplex wood using a 2mm cutting bit on my CNC machine. This allowed me to pre-drill 2mm mounting holes for the Raspberry, so I just needed 2.5mm screws that would instantly fix the raspberry to my frame. 

For the PI Camera, I designed a small and easy to print bracket (as I need 40 of them, so it needed to be small) that can hold the camera securely and would easily allow me to change the angle the camera would be pointing at.

To fancy up the poles I also added a 1meter strip of 60 LEDs to each one, to provide some extra light for the photos and just because it looked cool :-)



 

Step 2: Connecting everything up

Picture of Connecting everything up
photo (4.JPG

Connecting 40 computers with ethernet and power was going to be messy, but I wanted to do it as efficient as possible. Unfortunately the Raspberry PI does not support Power-over-Ethernet, so I had to make this myself. I cut 40 ethernet cables, each 5 meters long. I kept all cables the same length so I know that what ever voltage I would lose over this distance would be equal for all and I would be able to adjust this on the power supply to get a very accurate 5v.

As 100mb ethernet only requires 4 of the 8 cables inside an ethernet cable, I could use 2 for providing the 5v to the raspberry. So I ended up putting 80 (2x 40) connectors on the cables using just 6 of the 8 wires (2 not being used). I would say this was one of the most boring and tedious elements of this project :-(

I bought a bunch of female jumper wires, cut them in half and soldered 2 on the end of each network cable, so I could easily just fit this on the ground and 5v pin of the Raspberry Pi.

On the other side, I build a "power distribution board" from my single 60A 5v power supply to where I could easily connect all the 5v and ground wires to coming from each ethernet cable.

Step 3: The software

I am using Raspian OS, just the default download from the raspberry pi website.

To collect all the images, I am using a central file server (in my case I am using a Qnap). I configured the raspbian image to connect to the file server using cifs. This is done in the /etc/fstab file.

I am also using the central file server to store my software, so I can make modifications without having to update every raspberry on its own.

After I completed this image, I used dd (on my mac) to clone the SD card 40x for each raspberry.

I wanted to write a "listening" script that each raspberry would run, listening to a particular network broadcast package that would trigger the camera and then save the photo and copy it to the file server. As I want all the images to be stored in a single directory (one directory per shot), I am using the local IP address of each raspberry (the last 3 digits) for a prefix of the filename.

Here the python listening script I am using:

#!/usr/bin/python
import socket
import struct
import fcntl
import subprocess
import sys

MCAST_GRP = '224.1.1.1'
MCAST_PORT = 5007

sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sock.bind(('', MCAST_PORT))
mreq = struct.pack("4sl", socket.inet_aton(MCAST_GRP), socket.INADDR_ANY)

sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq)

def get_ip_address(ifname):
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
return socket.inet_ntoa(fcntl.ioctl(
s.fileno(),
0x8915, # SIOCGIFADDR
struct.pack('256s', ifname[:15])
)[20:24])

id = get_ip_address('eth0')

ip1, ip2, ip3, ip4 = id.split('.')

print 'ID: ' + ip4

#create an options file, this file should containt the parameters for the raspistill image cmd
optionfile = open('/server/options.cfg','r')
options = optionfile.readline()
optionfile.close()
print "optons: " + options

while True:
data = sock.recv(10240)
data = data.strip()
if data == "reboot":
print "rebooting..."
cmd = 'sudo reboot'
pid = subprocess.call(cmd, shell=True)
else:
print "shooting " + data
cmd = 'raspistill -o /tmp/photo.jpg ' + options
pid = subprocess.call(cmd, shell=True)
print "creating directory"
cmd = 'mkdir /server/3dscan/' + data
pid = subprocess.call(cmd, shell=True)
print "copy image"
cmd = 'cp /tmp/photo.jpg /server/3dscan/' + data + "/" + data + "_" + ip4 + '.jpg'
pid = subprocess.call(cmd, shell=True)
print "photo uploaded"


To initiate all the raspberries to take a photo, I created a "send script". That would ask for a name. This name is send to the raspberries to include in the prefix of the filename. So I know who the images are from.

Here the python send script:

import socket
import sys
import time

print 'photo name:'
n = sys.stdin.readline()
n = n.strip('\n')

MCAST_GRP = '224.1.1.1'
MCAST_PORT = 5007

sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 2)
sock.sendto(n, (MCAST_GRP, MCAST_PORT))


The listening script checks the name received. If the name is reboot, reload or restart it does a special action, instead of shooting a photo.

To configure what options I want to use for raspistill (the default image capture software on the raspberry for the PI camera) I am using an options.cfg file to configure this. Again this is stored on the central file server, so I can easily change the options.

I did some testing to see how in-sync all the Raspberry Pies would take the photo. As they all receive the network broadcast package at the exactly same time, I found this worked great. I did a setup test with 12 units all taking a photo of my iPhone running the stopwatch app. Each photo captured he exact same 1/10th of a second.

Step 4: Processing the images to a 3d model

Picture of Processing the images to a 3d model
memento_fixing.jpg
There are different ways how you can turn the photos into a 3d model. Personally I like autodesk’s recap the best.

Go to recap.autodesk.com. If you do not have an autodesk account yet, you can create one for free. It comes with 5Gb of storage, which is plenty enough to create your 3d model.

After you have logged in to recap, click on the new project button. Here you can select the quality of your 3d model (I always choose Ultra, why settle for lower). For the export format, most 3d printer software can directly work with .obj files, so at least select that one.

After that you can upload all your images by dragging them into your webbrowser, or by clicking you get a popup windows where you can select your photos.

Wait for the photos to be uploaded and click next 2 times. The autodesk cloud system will now start to do the hard work and turn your photos into a 3d model. This can take between 15 and 45 minutes. As this is happening “in the cloud”, you can do other things while waiting  [:-)]

When the heavy computing is done you can click in the middle of the thumbnail (on the eye) to see the model in 3d on your webbrowser. Important: this requires the Chrome webbrowser!

When viewing your 3d model, you should see a thumbnail gallery of your images on the left. If all went well, you should NOT have many (or ideally none) in the list called “Not Stitched”. This would mean that those images where not detected. You can try to fix this by manually clicking marking points on the images. But as I said, hopefully the 3d scanner took good enough photos of you that this is not needed.

You can now download the .OBJ file to your local computer for further processing and clean up, like removing the background. The file you download is again a zip file. So you need to unzip this before moving on to the next step.

Cleaning up your 3d model.

There are many programs available to clean up your 3d model. The easiest program I have found to do this is also a free product from autodesk called “project memento”. You can download memento (Only for windows!) here: http://labs.autodesk.com/utilities/memento

After you have installed project memento, you can directly open up the downloaded .obj file, it should be called mesh.obj. The photos taken by the 3d scanner are 90degrees turned. This means that your model probably has an incorrect feeling for up and down. In the botton left you will get a message “did the orbiting feel off?”. Click on “feels off” to correct this.

You correct the orbit, click for instance on the top of your head, making sure that the arrow is pointing up. Try rotating the model (by keeping your right mouse button pressed). If it feels good now you can accept the setting.

As you can see, you where not only scanned, but also part of your environment. You probably want to cut those pieces away. This is very easy in memento. Just select with your mouse a region of unwanted stuff and then hit delete. By rotating the model around you should be able to easily select and remove all unwanted stuff.

Fix your model for 3d printing.

To be able to print your model on your 3d printer, you need to make sure you have a watertight model (no holes in it). Again this can easyly be fixed with memento. Click on the top middle of the memento window and you will see a popup to fix your model.

Just walk thru the wizard and any hole issue it finds, click on fix. You need to select if you want a flat or smooth fix. For me usually the flat fix works best. Select “next” again to find more issues. The holes need to be fixed, everything else is optional.

After you have fixed all the holes, click done and now you can export the model as a new .obj file. You can do this by going to the top left corner of the mement program and click on the bended arrow.

You can now specify how detailed you want to save your model. Again here, why go for lower resolution?? move the slider all the way to the right to get the best quality.

You are somewhat done now. You have a printable 3d model. If you want to clean the model more up there are some programs that can help you with that.

Pixologic Sculptris (free): This is a great program to fix little details in your model, like smoothening out areas. it is like a photoshop, but then for the 3d world.

Meshmixer (free): An other free program from autodesk. Meshmixer is great to for instance make a flat bottom on your model.

Alternative software to make a 3d model

Besides Autodesk Recap there are more options to turn your photos into a 3d model.
Autodesk 123d Catch (free): It works like recap (being a cloud service), it a bit better developed then recap, but does scale down your images. So the end result is a bit less resolution.

VisualSFM (free): This is local (and much more complicated) software to turn your images into a 3d model. You need a powerful graphics card (supporting cuda) to run this software.
Agisoft Photoscan Standard Edition ($179): Also for this software you need a powerful pc and so far I have not found that this produces better results that Recap or 123d catch.

Step 5: Results

After building this project, there is of course no greater fun then sharing the "machine" with others. So I decided to participate in the Dutch maker faire and offered everyone a free 3d photo shoot. I can tell you it was a very busy but fun 6 hours and we scanned 225 people! You can read more about it on my blog: www.pi3dscan.com
 

Step 6: Design files

Here are the design files I used. The "statief" is an 2d cad file for the poles that I cut out on my CNC.

The camera_mount files are the camera brackets I designed.
 

Step 7: Version 2

Picture of Version 2
52f0e822c6ba5d5628000002.jpg
52f0e80ec6ba5d1e4a0000af.jpg
52f0e833c6ba5d1e4a0000b1.jpg

A few months doing the Makerfaire show, I was invited for another exhibit to demonstrate my 3d scanner. I wanted to make the set more portable and easier to adjust. So I redesigned the frame. instead of using only wood, I designed tripods from cheap radiator pipes. This allows me to easily move the cameras up and down. I already designed new 3d printed brackets for the raspberry and camera that slide over the radiator pipes (40mm).

You can already download the tripod design on thingiverse: http://www.thingiverse.com/anykey/designs and I will soon be adding the raspberry and camera mount to it as well.

I am currently using 47 camera units. This allows me to do full body scan of kids (up to 1.20m). I will need to add more cameras to do full body scan of an adult.

1-40 of 102Next »
blurbbox1 month ago

Hi Richard,

Could you please help with the formatted code.

It gives an error saying indentation needed.

Regards,

Anant

hi Richard, nice job indeed. would be nice to see the raspberry and camera mount 3d model u used for printing as well .im very bad in 3d and i cannot use proficiently 3d software.thank you

azadeha2 months ago

Hello Richard, I wonder that in your latest build for the camera poles you didn't use a curvy structure. Didn't you find it very influential? Another question is that are you able to do a full body scan because I don't see any raspberry pi at the lower height.

Thanks

peterjaap3 months ago

I've seen this live (at the place where the main photo is taken)! It's awesome :) Here are two photos I took.

2013-10-12 14.23.22.jpg2013-10-12 14.23.32.jpg
fengkan4 months ago

I am trying a familiar setup. But I found it's very difficult to get pi cameras to take photos of same color. Some photos are too yellow, some are too white, some are too gray. I have specified the awb and exposure parameters. Have you met the same problems?

fengkan fengkan3 months ago

Any hint will be welcome, thank you!

peteyhockey93 months ago

Could you please email me the correct code to cpeterson19@gmail.com

Thank you so much

fgrande4 months ago
Hy, now everything is ok!! Now i'm waiting more raspberry to do adult scanning.
My problem is that, if my raspberry is connected to internet (in my case I’m using wifi adapter), the listen code start with no problem; if there is no internet connection python give me an error (see image attached).
My question is: Why is required an internet connection? Is it possible to modify the python code and disable this request?
the_anykey (author)  fgrande3 months ago

Hi,

The code assumes you have an local IP address to use as identifier for saving the images. When you say you have no internet connection, do they get an local ip address from dhcp? if not, you have to setup manual ip address on the raspberry

roscowillie5 months ago

getting closer. Substituted

<print 'ID: ' + ip4>

for < print "ID" ip[caret underneath]4 "-">

now I get:

<print "optons: "optio[caret underneath]n

SyntaxError: invalid syntax.

sorry to be so clueless. Noticed that maybe optons should be spelled options, however this is obviously not the syntax error. Tried single quotes same report.

the_anykey (author)  roscowillie5 months ago

The instructables page does not allow me to post the code correctly i noticed. Python needs idents for certain segments in the code. Send me a mail with your email and I will email you the code.

Richard,

I pm you with my email addressing regarding emailing the properly formated python scripts.

Thanks

John Ang

azadeha5 months ago

I can see you don't use green wall but it's interesting that in the first maker fair, there was lots of windows on one side and natural light was coming but it didn't effect your work negatively. When I was 3D scanning with Kinect, natural light wasn't good at all.

the_anykey (author)  azadeha4 months ago

Hi, I kinect works with infrared light. If you have bright sunlight, this "overwrites" the infrared light and therefor you will have issues with it. As we do not rely on infrared light, the more light we get, the better it is. Preferably all around, as we do not want to have shadows in our models. Today we are using a 11 softboxes all around to light the subject.

johnacsyen4 months ago

Dear Richard,

Where do you run the "send script"? Is it from a computer running the python application and then calling this send script? I assume this computer is in part of the network together with the Raspberry Pis.

Sorry for asking an obvious question but I am new to python.

Thanks for your help

the_anykey (author)  johnacsyen4 months ago

Hi, You can run the send script from any thing that is connected to the same network segment. I just use any of the raspberry system for it, but it can also be done from a PC or Mac

azadeha5 months ago

Richard as for the light, I can see in your newer version you're using 8 of those standing lamps. Do you really need so many? Every pair of them is at least $300, isn't it? LED strips were only for kid-friendly purposes, weren't they?

the_anykey (author)  azadeha5 months ago

I found that good lights is crucial to get good photos. I am shooting at 100ISO at 1/80th shutterspeed with my lights. Also you want to have lights all around to make sure there is no shadow in the images.

My lightboxes, which include 4x55watt special film studio lights cost about 100 euro each.

Richard, thank you for your quick replies. I guess your lamps are more like this: http://www.amazon.co.uk/dp/B008JDMEWW/?tag=athok07...

But I didn't find any thing like that for €100 but I found these: http://www.promaster.com/products.asp?product=9420 which are the same price as yours. What do you think about them? The only thing I can think is that in your case if one of the lamps burns still 3 more are functional but in the second product is only one lamp.

the_anykey (author)  azadeha5 months ago

Your like is for flash heads, I am using permanent lighting. This is what I use: http://www.folux.nl/ss-19-softbox

Maybe this is more like yours and permanent lights: http://www.amazon.ca/CanadianStudio-Continuous-Flu...

Do you think any lamp from above is of any use?

roscowillie5 months ago
Richard,

I thought those posted photos were with 24. What kind of results are you seeing withe 47? What do you expect with 70. Lastly, how are you configuring the cameras (ie 10deg x 4). You're really taking this to the next level.
the_anykey (author)  roscowillie5 months ago
You can do like upper body with 24, but to do full body, supporting many different poses requires a "few" more :-) We are setting up on most poles 4 cameras, some (face area) have one extra. we are using 16 pole, about 320 degrees around (opening in the back, to walk in)
Got it. Have you been able to achieve anywhere close to the quality of these guys? http://www.ten24.info/?page_id=302
the_anykey (author)  roscowillie5 months ago

Well the quality of our scans if way higher then what the 3d printers can print. So for our purpose we are fine, but sure we do not get the same results as ten24 :-) But our investment is 1/100 of theirs :-) and I do not think we get 1/100 quality. You can see some scan results on www.sketchfab.com/3dmij

roscowillie5 months ago

Richard,

I finally got the script to trigger a three camera wifi setup. It seems to work pretty well. I'm using the Model A, Cam, Edimax Wifi, 8 gb. I'm considering going for 24 (12 x 2) to capture people (15 ft diameter). Is this overkill? What have you settled on for your shooting configuration? Also, have you done any more experimentation with agisoft photoscan?

Thanks again for your creative thinking and tenacious making.

the_anykey (author)  roscowillie5 months ago

Hi, There is never overkill (well unless you use 200+ cameras) :-)

I can not capture a full body adult with just 24 cameras. I currently have 47 working and upgrading this week to 70 to enable full adult scanning.

makerT5 months ago

Hi, i 'am trying to scan part of objects with 6 Raspberry Pi...but i have some problem becouse i'am not expert.

I have a D-link DES-1008D switch were i connected all the 6 Raspberry. Each raspberry has an IP address 192.168.0.100/101/103/...106.

Now what i have to do? Using WinSCP i have to connect to one raspberry and launch the script?

Thanks for the help

the_anykey (author)  makerT5 months ago

The way how I do it, is to have the code sit on central storage. So all raspberries connect to that and run the listen code from there. So you do not have to distribute the code and also makes it easy to update it. You can then use any raspberry (via SSH connection) to initiate the "click" scipt that will fire off the network broadcast.

azadeha5 months ago

Hello Richard, Thank you very much for uploading your solution. I am making it. I'm so excited. Qnap is not a free file server, is it? Do you have any special reason for using this file server?

the_anykey (author)  azadeha5 months ago

The QNAP is just what I am using. You can use any kind of shared storage, like you local PC. Just make a windows share, that is the same as the QNAP..

azadeha5 months ago

Hello Richard again, I assume the more RAM, Raspberry pi has better, so I better order 512 MB, don't I?

the_anykey (author)  azadeha5 months ago

To shoot the image and upload the image does not really require a lot of ram, so both Model A or Model B can work. I prefer model B, as I want to use fixed LAN and not wireless.

makerT5 months ago

Hi, another question: is it possible to use Raspberry Pi as NAS for Multiple Raspberry PI 3D Scanner?

http://www.raspberrypi.org/phpBB3/viewtopic.php?t=...

Thanks

the_anykey (author)  makerT5 months ago

Technically you can use anything as your NAS (central storage), your windows machine, a raspberry. In practice it will have to depend on how many cameras you have. The networking from the raspberry is slow (100mb and over usb bus on the raspberry). Trying to upload many images at the same time might take a very long time.

makerT5 months ago

Hi resconwillie,

thank you for your reply... now I understand how to load the program.

Another thing that I did not understand is what is used for the NAS Server. As hard disk or something else? Can i use my pc as hard disk instead of NAS?

.....sorry for my obvious questions...but I would need a step by step guide...

roscowillie5 months ago

Hi makerT,

I'm attempting a wifi implemenation. If you're hooking up per Richard's instructions, you should be able to cut/paste the listen script code into IDLE and run from Wheezy on the pi. First, you'll need to make a quick options.cfg file (see below). You'll also need to tweak the server location after you've set up an NAS or served directory connection. Once you've done all that, just 'run module F5' and go to your pc for next step.

Don't know what os you're triggering from, but you just load python up and paste the trigger code into IDLE. Run the trigger file 'run module F5'. I was using WinSCP to transfer/tweak files. Shouldn't need it for regular operation. Just two pieces of code from Richard.

Foxtrot70, not sure yet. Depends on the # of cameras. I'm not buying more than 3 until I'm confident I can get it to work.

Foxtrot705 months ago

What was the total cost of this project?

roscowillie5 months ago

Richard,

Thanks so much for following up on the correct coding format. I figured out the syntax just about the same time I noticed you had fixed it on this page!!!! My last stage of flailing involves making multicast work with my network. I finally dumped my main net and have a stand-alone wifi router connected wirelessly to computer and target pi. The Pi takes UDP triggers fine, but just doesn't get the 224.1.1.1 multicast. I have uPnP & rip 2_B started on the router (a netgear wnr3500l with lastest stock firmware). I've tried triggering with Packet Sender and I just can't get the multicast trigger. You said you got the wifi setup to work. Any insight? By the way, the code I'm turns out to be pretty much what you posted save a swap of wan0 for eth0 and the server locations. My options file is simply -t 1 -q75. Thanks again for you all your work.

fgrande5 months ago

Congrats for the win!!!

1-40 of 102Next »