3D Camera (with Raspberry Pi)

Introduction: 3D Camera (with Raspberry Pi)

Although 3D camera's are usually said to be really intricate, hence their price, it turned out the basic principles aren't really that difficult to replicate. Granted it is troublesome to get the quality of professional products, compared to their cost, this is a neat homebuilt alternative.

Built your own for less than $100 (depending on desired quality and amount of parts already owned).

It uses 2 usb webcams to capture and process images to .jps (stereo .jpg), ready to view on a 3D screen.

Step 1: Parts and Equipment

These are the parts I used. For some of them there are alternatives, but I decided these to have the best quality for their price.

1. Raspberry Pi (model B) and SD card (class 10 recommended, though 6 should also do the job)

2. Piface Digital

This is an interface to use with you RPi to simplify inputs and outputs (for example, switches and lights)

3. 2x webcam

I used Trust Widescreen 1080p, although any usb webcam should do.

4. Battery

Any usb powerbank should do. For comfortable use, I recommend a capacity of at least 3000 or 4000 mAh. I used one of 15.000 mAh, since I had it laying around. But again, since the RPi doesn't use that much power, you don't need all that much to be able to photograph for a few hours.

5. Misc parts

I ended up using 1 switch, 1 button (on)/off, 1 small LED and one resistor.

Be careful with this LED. The Piface Digital outputs 5V, if I'm not mistaken, witch is too much for most LED's. Hence, the resistor. There are plenty of websites that can calculate the amount of Ohm's needed to reach the desired voltage and/or amperage.

6. Cardboard and some tape (or whatever you want to make the casing out of)

Perhaps some time, I design and print a case, but for now cardboard was the easiest and cheapest.

As for equipment, some scissors, a cable stripper and a very small screwdriver are all you need.

For a more durable and higher quality result you would also need a soldering iron.

Step 2: Programming Your Pi

First things first. If you haven't done this already, install your Piface Digital according to the manual. You can check if all went well with the onboard software. If the integrated LED's turn on on command, it works.

I used Python to make the Piface Digital respond to several button and switch inputs, as well as LED output and camera functioning. You can use my code, but note that it is based on a on/off switch (as opposed to an (on)/off switch, i.e. one that doesn't stay on). Everything else should work as is. If it doesn't, you might have to rename your camera numbers (e.g. (0) to (1) ).

Also, all the input and output port numbers are based on the ones I used. If you decide to use different ones (you rebel) please change them accordingly in the code. I used output no. 5 for the LED, input no. 2 for the "shutter" and input no. 3 for the off-switch.

Step 3: Build the Case

If you ran out of money at this point (like I did), you might want to build the case out of cardboard. Just about any cardboard box will do, but I recommend it to be 3 to 5 mm thick. Any less will probably not be sturdy enough, any more will be difficult to build with.

So, if you've found your desired cardboard box, you might want to go over to a website like templatemaker.nl

Just pick a box and fill in the desired dimension. (NB you are going to have some cables that need some room, design accordingly) Just make sure you don't make them too large, else you're going to have a rough time printing this template.

Finally, just trace the paper on cardboard, cut out the pieces and tape (or glue) them together.

Leave the back open for the next step!

Step 4: Build the Interior

Now, since you most likely have at least one part different from the ones I used, my final interior layout may not be suitable for you. If not, you can use mine as an idea for your own.

The picture is taken from the back. What is underneath this can be seen on my "high-quality" technical drawing.

Every part, except for the camera's, are held in place purely by pressure.

Step 5: Results (+ Improvements)

At the moment, I'm still working on aligning the camera's. This turns out the be the biggest problem, which I believe can be fixed in true engineering fashion, by applying more duct-tape to hold the camera's in place. If you don't want to risk ruining your camera's, you could try to build a better box around them with excess cardboard or perhaps 3D print a case.

Another problem I ran into is that the RPi has some issues with handling 2 usb camera's. Even though they don't snap pictures simultaneously (which is a problem on itself), still sometimes one of the pictures is off-colour, mostly greenish. Although I'm not sure, I think this can be fixed by not using Python to run the system, but for example C, as this runs quicker and more smoothly.

Edit

If I ever decide to build a version 2, I might use something like this. No need to align and probably more CPU and GPU friendly.

Raspberry Pi Contest

Participated in the
Raspberry Pi Contest

Be the First to Share

    Recommendations

    • For the Home Contest

      For the Home Contest
    • Game Design: Student Design Challenge

      Game Design: Student Design Challenge
    • Big and Small Contest

      Big and Small Contest

    8 Comments

    0
    Meghanv
    Meghanv

    7 years ago

    Hi, I have a question about facial recognition.

    I would like to make a fool proof facial recognition system, and using motion doesn't necessarily work for me. This is the problem with trying to detect motion: http://www.popsci.com/its-not-hard-trick-facial-r...

    Therefore I would like to use a 3D camera to save the facial matrix. Could I use the 3D software in order to detect if the image taken has a flat surface (such as a photo) so that you can't spoof the facial recognition?

    Thank you in advance :)

    0
    kakungulu
    kakungulu

    7 years ago on Introduction

    How many cameras can you connect? I've been a 3D enthusiast since the 1980's, when you had to do alignment on 35mm printed photos with scissors and tape... Now I'm thinking about lenticular photography, which takes at least 4 images in parallel. If I can find good quality (maybe 5MP) webcams and connect them via USB hub to a RaspPi, I could take 4 frames in parallel. Do you think that'll work?

    0
    PaulB85
    PaulB85

    Reply 7 years ago on Introduction

    @kakungulu: forget Webcams (poor resolution, "quality", low-light-"quality", noise...) ...you must use the PiCam (REAL 5 MP!). problem: you can only connect one cam on Rpi. So you need two up four Rpi's + Cams. The Rpi's must be connected and synchronized for the picture (or 3D-Movie!)

    0
    kakungulu
    kakungulu

    Reply 7 years ago on Introduction

    Thanks, that's what I was planning before I saw this 'table. But I wanted to avoid having to use an Rpi per camera. At least now I know I'm not (the only?) crazy to think about that.

    Plus, I wanted more than the minimum 4 cameras. Full lenticular card takes 12 images! Another application: light field photography, which again uses an array of cameras.

    As for quality, you're absolutely right. But that can be compensated by only taking well-lit family portraits and grand view, mid-day "postcard" type of pictures that at least have high signal/noise ratio. Going into DIY 3D, you're bound to make compromises on quality anyway. No one straps two high-end DSLR's together for the pro-looking AND 3D photos...

    0
    gtoal
    gtoal

    Reply 7 years ago on Introduction

    I wanted to mix 8 video images in real time for live streaming video on a lenticular screen, but the pi did not appear to have the bandwidth. I haven't done the calculations again now we have the rpi2 (because unfortunately I no longer have access to the 3D display...)

    0
    konovalov
    konovalov

    Reply 7 years ago on Introduction

    4 usb webcams simultaneously? Never tried, but I guess if you can write a script that manages to utilize all webcams at the same time, it might work (emphasis on might). I'm no programmer so I don't know if there are Python modules to let you capture from multiple webcams at the same moment. If you do, problem might then be the quality of the images, since I don't know if the RPi can process that much at once. Images might become discoloured etc. Maybe the RPi 2 can though or perhaps through clever programming...

    0
    AlexC67
    AlexC67

    Reply 7 years ago on Introduction

    You can utilize all the cameras, being a programmer, you write those modules, but it is definitely no easy task.

    0
    gtoal
    gtoal

    7 years ago on Introduction

    Wow. 30 quid for that 3d webcam in the UK? It's $20 in the US :-/ http://www.amazon.com/Minoru-3D-Webcam-Red-Chrome/dp/B001NXDGFY/