9
http://www.instructables.com/id/Multiple-Raspberry-PI-3D-Scanner/ Food Living Outside Play Technology Workshop Multiple Raspberry PI 3D Scanner by the_anykey on November 12, 2013 Table of Contents Multiple Raspberry PI 3D Scanner . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Intro: Multiple Raspberry PI 3D Scanner . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Step 1: Setting up the hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Step 2: Connecting everything up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Step 3: The software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Step 4: Processing the images to a 3d model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Cleaning up your 3d model. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Fix your model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Alternative software to make a 3d model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Step 5: Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Step 6: Design files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 File Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Related Instructables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Advertisements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

Instructables.com - Multiple Raspberry PI 3D Scannermesh.brown.edu/dgp/final-project/Multiple-Raspberry-PI-3D-Scanner.pdf · Hi, I am Richard, Father of 1 son + 2 step sons, so we

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Instructables.com - Multiple Raspberry PI 3D Scannermesh.brown.edu/dgp/final-project/Multiple-Raspberry-PI-3D-Scanner.pdf · Hi, I am Richard, Father of 1 son + 2 step sons, so we

http://www.instructables.com/id/Multiple-Raspberry-PI-3D-Scanner/

Food      Living       Outside        Play        Technology       Workshop

Multiple Raspberry PI 3D Scannerby the_anykey on November 12, 2013

Table of Contents

Multiple Raspberry PI 3D Scanner . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

Intro:   Multiple Raspberry PI 3D Scanner . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

Step 1:   Setting up the hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

Step 2:   Connecting everything up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

Step 3:   The software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

Step 4:   Processing the images to a 3d model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

Cleaning up your 3d model. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

Fix your model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

Alternative software to make a 3d model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

Step 5:   Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

Step 6:   Design files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

File Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

Related Instructables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

Advertisements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

Page 2: Instructables.com - Multiple Raspberry PI 3D Scannermesh.brown.edu/dgp/final-project/Multiple-Raspberry-PI-3D-Scanner.pdf · Hi, I am Richard, Father of 1 son + 2 step sons, so we

http://www.instructables.com/id/Multiple-Raspberry-PI-3D-Scanner/

Author:the_anykey    pi 3d scannerHi, I am Richard, Father of 1 son + 2 step sons, so we have a house full of Lego. I have had lego for decades, including Lego mindstorms. I like to makethings. In my little garage I have a large CNC machine, 3d printer, milling lathe, electric saws, etc. I work in IT (for Oracle), but when not working I like to bebusy with my mind, hands and kids :-)

Intro:  Multiple Raspberry PI 3D ScannerHi,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 3dscanner. 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 meto 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 cheapmodel, 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 acheap 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 camerasusing 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 NOTneed 40 cameras, especially not if you just want to catch just the front of a persons face.

Here a result output:

Step 1: Setting up the hardwareSo 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 andhard 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 shootfrom 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 Ijust 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 allowme 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 :-)

Page 3: Instructables.com - Multiple Raspberry PI 3D Scannermesh.brown.edu/dgp/final-project/Multiple-Raspberry-PI-3D-Scanner.pdf · Hi, I am Richard, Father of 1 son + 2 step sons, so we

http://www.instructables.com/id/Multiple-Raspberry-PI-3D-Scanner/

Page 4: Instructables.com - Multiple Raspberry PI 3D Scannermesh.brown.edu/dgp/final-project/Multiple-Raspberry-PI-3D-Scanner.pdf · Hi, I am Richard, Father of 1 son + 2 step sons, so we

http://www.instructables.com/id/Multiple-Raspberry-PI-3D-Scanner/

Step 2: Connecting everything upConnecting 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 supportPower-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 wouldlose 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 theRaspberry 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 fromeach ethernet cable.

Page 5: Instructables.com - Multiple Raspberry PI 3D Scannermesh.brown.edu/dgp/final-project/Multiple-Raspberry-PI-3D-Scanner.pdf · Hi, I am Richard, Father of 1 son + 2 step sons, so we

http://www.instructables.com/id/Multiple-Raspberry-PI-3D-Scanner/

Step 3: The softwareI 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 isdone 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 thephoto 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/pythonimport socketimport structimport fcntlimport subprocessimport 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, # SIOCGIFADDRstruct.pack('256s', ifname[:15]))[20:24])

id = get_ip_address('eth0')

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

print 'ID: ' ip4 '-'

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)elif data == "reload":optionfile = open('/server/options.cfg','r')options = optionfile.readline()optionfile.close()elif data == "restart":cmd = '/server/reload.sh&'pid = subprocess.call(cmd, shell=True)else:print "shooting " datacmd = 'raspistill -o /tmp/photo.jpg ' optionspid = subprocess.call(cmd, shell=True)print "creating directory"cmd = 'mkdir /server/3dscan/' datapid = 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 thefilename. So I know who the images are from.

Here the python send script:import socketimport sysimport time

Page 6: Instructables.com - Multiple Raspberry PI 3D Scannermesh.brown.edu/dgp/final-project/Multiple-Raspberry-PI-3D-Scanner.pdf · Hi, I am Richard, Father of 1 son + 2 step sons, so we

http://www.instructables.com/id/Multiple-Raspberry-PI-3D-Scanner/

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 configurethis. 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 foundthis 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 modelThere 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 your3d 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 theexport 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 cantake 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 theChrome 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, hopefullythe 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 “projectmemento”. 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 are90degrees 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 buttonpressed). 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 selectwith 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. Clickon 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 programand 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 modelBesides 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 bitless 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 runthis 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 123dcatch.

Page 7: Instructables.com - Multiple Raspberry PI 3D Scannermesh.brown.edu/dgp/final-project/Multiple-Raspberry-PI-3D-Scanner.pdf · Hi, I am Richard, Father of 1 son + 2 step sons, so we

http://www.instructables.com/id/Multiple-Raspberry-PI-3D-Scanner/

Step 5: ResultsAfter 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 offeredeveryone 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

Page 8: Instructables.com - Multiple Raspberry PI 3D Scannermesh.brown.edu/dgp/final-project/Multiple-Raspberry-PI-3D-Scanner.pdf · Hi, I am Richard, Father of 1 son + 2 step sons, so we

http://www.instructables.com/id/Multiple-Raspberry-PI-3D-Scanner/

Step 6: Design filesHere 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.

File Downloads

stafief_v3.dxf (79 KB)[NOTE: When saving, if you see .tmp as the file ext, rename it to 'stafief_v3.dxf']

Page 9: Instructables.com - Multiple Raspberry PI 3D Scannermesh.brown.edu/dgp/final-project/Multiple-Raspberry-PI-3D-Scanner.pdf · Hi, I am Richard, Father of 1 son + 2 step sons, so we

http://www.instructables.com/id/Multiple-Raspberry-PI-3D-Scanner/

camera_mount.scad (586 bytes)[NOTE: When saving, if you see .tmp as the file ext, rename it to 'camera_mount.scad']

camera_mount.stl (215 KB)[NOTE: When saving, if you see .tmp as the file ext, rename it to 'camera_mount.stl']

Related Instructables

Raspberry Pi aswebserver. byantares72

Install awebserver onRaspberry Pi. byantares72 Use ssh to talk

with yourRaspberry Pi. byantares72

Configuring theRaspberry Piethernet port forremote controlby ZRob314

How to add aReal time clockto theRaspberry Piopen sourcehardware byelectronicshouse

ConnectRaspberry Pi toProjector or TVby tim.ding

Advertisements

Comments

1 comments Add Comment

 audreyobscura says:  Nov 12, 2013. 11:30 AM  REPLYBeautiful design and awesome results! Great work!!!