Wallace and Gromit, two of the world's best-loved animated characters, started out life as primitive lumps of colored putty. But like other non-digital animation, they're brought to life by painstakingly photographing a scene 24 times for every second of footage.

You don't need high end equipment to make your own movie though: in this age of high resolution digital cameras or smartphones, anyone can have a go. Here at MakeUseOf.com we've looked at various examples of stop-motion camera apps over the years for smartphones, and these are a great solution.

But what if you wanted something a little more permanent? If you own a Raspberry Pi with the PiCam camera module, you're already well on the way to building your own stop-motion animation studio!

Get Your Bits Together

For this project, you'll need a Raspberry Pi computer and the PiCam module, which is compatible with all versions of the Pi. If you don't have one already, these are inexpensive digital camera modules with 1080p video capability available for just under $30 on Amazon.

That is just the basics, however. If you're planning to build the full top down setup for table top animation (including cel animation, as used by cartoonists) then you'll also need to put together a rostrum – essentially a stand or rig for holding our stop motion PiCam.

You may prefer to avoid this if you're doing side-on, Wallace & Gromit style animation, for which you'll just need a suitable grip for the Raspberry Pi and PiCam, and a tripod. Alternatively, a dashboard mount for a smartphone may prove invaluable.

muo-diy-rpi-stopmotion-button-dashboard-mount

What might also prove useful is a Raspberry Pi case that allows you to mount the camera, like the one pictured above. These can be picked up quite cheaply on Amazon.

Finally, you might appreciate the addition of a button to take the photos, rather than typing a command into your Pi over SSH. For this you'll need a solder-free breadboard, two male-to-female wires, and a dual-state push button.

While you mull over that, here's a video on how to build plasticine rabbits.

Setup the PiCam Module

If you haven’t yet setup the PiCam, then you'll need to begin by connecting it to your Raspberry Pi.

You'll find the destination socket a short distance from the Ethernet port, although its exact location depends on which Raspberry Pi module you're using. Begin by raising the plastic clip on the socket, then slot the PiCam's flex cable into position, the side with the metal connectors facing away from the Ethernet cable.

With a PiCam module attached you can engage in all manner of projects from using your Pi as a security camera, to turning into a video camera. We recently looked at a number of great Raspberry Pi camera projects which you might like to take a look at before proceeding.

Configuring the Raspberry Pi as a Camera

With the PiCam connected, it's time to plugin and boot your Raspberry Pi as normal. You'll be fine using the Raspbian operating system, which can be installed manually to your SD card or if you prefer a little hand holding, using the NOOBs tool.

Once booted up and correctly configured (typically with sudo raspi-config), it's time to start testing the camera. Boot into the GUI (enter startx if you have booted to a screen of text) and in the command line, enter:

        raspistill -o image1.jpg
    

A photo of whatever is in front of the camera will be snapped, which you will find by opening the File Manager and viewing the Home directory. Double click to open the image for further investigation – you'll notice it is upside down.

(If you want to take more images now, just change the filename in the command, from image1.jpg to image2.jpg, etc.)

So, the PiCam is working.

Introducing Stop Motion

Next, it's time to enter some Python code to begin capturing your animation subject.

Start a new Python project and enter the following:

        import picamera
from RPi import GPIO

button = 17

GPIO.setmode(GPIO.BCM)
GPIO.setup(button, GPIO.IN, GPIO.PUD_UP)

with picamera.PiCamera() as camera:
camera.start_preview()
frame = 1
while True:
GPIO.wait_for_edge(button, GPIO.FALLING)
camera.capture('/home/pi/animation/frame%03d.jpg' % frame)
frame += 1
camera.stop_preview()

Save this as something recognizable, such as animation.py.

Construct and Connect Your Button

We can now capture images, which are automatically saved into a folder on your Pi's storage. To automate the process further, we can connect a button to the Pi's GPIO array to snap each image in the animation sequence.

Connect a button to your non-solder breadboard as illustrated, connecting the two wires to pins 6 and 11 on the GPIO header (or GND and GPIO17).

muo-diy-rpi-stopmotion-button-fritzing

Once connected, you'll be able to press the button to take each shot on your stop motion camera. Rather than run in Python, however, you'll need to open a new Terminal window and enter:

        sudo python3 animation.py
    

With this running, your stop-motion project will capture the desired image with each button press. However, when you're all done, you'll need to press CTRL+C to terminate the script.

Building Your Rostrum Rig

Various options are available for building a rostrum. You might, for instance, opt for a wooden DIY setup like this:

Alternatively, you could use LEGO, or perhaps Meccano:

muo-diy-rpi-stopmotion-button-meccano-rostrum

Thanks to things like mobile phone holders and tripods, however, we don't really need to worry too much about building a traditional rostrum, as technology has moved on considerably since the days those devices were used.

Stitching it All Together

At the moment, your stop-motion project will simply be a collection of images saved to the same directory (as specified in the script).

To turn these snaps into a film, you'll need to use ffmpeg, which you can install with

        sudo apt-get install ffmpeg
    

Open a Terminal window and enter the following script, taking care to appropriately alter the file path if you used something different.

        ffmpeg -y -f image2 -i /home/pi/Desktop/stop-motion/frame%03d.jpg -r 24 -vcodec libx264 -profile high -preset slow /home/pi/Desktop/stop-motion/animation.mp4
    

When you're ready, use the OMX Player to watch the animation:

        omxplayer animation.mp4
    

Too Much Code? Try This

If you prefer a less manual approach that relies on mouse input, then the stopmotion package for the Raspberry Pi is ideal. This requires that you first install the raspicam-extras package, so use the following:

        sudo apt-get install uv4l uv4l-raspicam uv4l-raspicam-extras
sudo apt-get install stopmotion
muo-diy-rpi-stopmotion-app

Stopmotion is a desktop application. All you need to do is ensure the camera is detected, line up your shot, and click the capture button. We had some problems with the export function (File > Export) but this should allow you to output the stitched-together images as an AVI file.

Two Ways to Make Stop-Motion Movies with Your Raspberry Pi

It is always good to have an alternative to fall back on. While we like the rawness of the manual switch stop-motion solution, it has to be said that the stop-motion app is very easy to use. In terms of results, there is very little to choose between the two, however, so we'll leave it up to you to decide which one you'll use.

Feel free to share the results of your stop-motion PiCam labors in the comments below!