In this tutorial I'll show you how to configure the Raspberry Pi and camera to create your movie using simple and free stopmotion software. By default the pi camera module is not supported by standard video subsystems so after assembling your hardware, you'll install a compatibility layer and the stop motion software.
Gather the Components
- Raspberry Pi—Model B with power supply, case, and SD card
- Pi compatible Wi-Fi adapter
- Raspberry Pi Camera Module
- Raspberry Pi Camera Module Extended Cable—12" or longer if you like
- Raspberry Pi Camera Module Mounting Kit
- Tripod or stand for the Raspberry Pi camera
- Nuts that thread onto a standard tripod post. UNC 1/4"-20 thread.
- Pi Compatible Monitor, HDMI cable, Keyboard, and Mouse. A Keyboard with a built in USB port for the mouse will help simplify the setup.
- Something to film. LEGO minifigs make an excellent subject
Assemble Raspberry Pi Camera
The Pi camera comes with a short ribbon cable which makes it difficult to mount and attach to a tripod or move far from the Pi itself. The following instructions will guide you through replacing the cable with a longer one, attaching the camera to the Pi, and mounting it on a tripod.
- Hold the camera module with two fingers with the lens facing away from the palm of your hand
- Locate the ribbon cable connector on the bottom camera module
- Using your other hand, put a finger on either side of the connector pull the connector down releasing the cable
- Gently pull the cable out of the connector
- Slide one end of the new, longer ribbon cable into the connector keeping the blue side of the cable pointed away from the board and the tinned side towards the board
- Slide the connector closed securely
Connect the camera cable to the board.
- Locate the camera connector on the Pi directly behind the Ethernet port
- Use two fingers to pull the sides of the camera connector up from the board
- Slip the ribbon cable into the connector keeping the blue side towards the Ethernet port
- Slide the connector back down securely
Assemble attach the camera to the camera mount kit.
- Connect the camera module to the plate with the lens hole and four screw holes
- Carefully slide the screws through the holes and thread the nuts onto the screw
- Tighten each one gently so as to not break the camera board
- Clip the bottom board into the bottom notches so that it looks like the image below
Attach the camera mount to the tripod. The camera module just needs to be held still for the duration of the stop motion capture session. Any mounting that will hold the camera still will work. In my experimentation I discovered a tabletop tripod worked well, but required a couple extra nuts to help the Pi camera mount fit securely.
- Slip the base of the mounting over the mounting screw of the tripod
- Use one of the threaded nuts to secure the board onto the tripod. If the screw shaft is too long screw one of the nuts onto the shaft first to form a base for the mounting bracket. The mounting bracket will help stabilize the camera for your shoot, however some finagling may be required to get it situated conveniently
Setup the Raspberry Pi
Install the latest Raspbian operating system on the SD card. There are several guides available on line help in purchasing a Pi, compatible components, and installing an OS. The following steps describe connecting the peripherals to the Pi and configuring the options.
Tip: If you need to know more about flashing an SD Card, for your Raspberry Pi, just refer to our tutorials: How to Flash an SD Card for Raspberry Pi and How to Install NOOBS on a Raspberry Pi With a Mac.
- Insert the USB wifi adapter into the top USB port on the Pi
- Connect the mouse and keyboard to the Pi–This may require a USB hub unless the mouse and keyboard can share the same port. Some keyboards have built in USB hubs that can accommodate a mouse. These make a good choice for the Pi
- Connect the HDMI Monitor
- Insert the SD Card
- Connect the power supply
- Perform first time setup configuration. Make sure to choose the following options:
- Enable Boot to a Desktop > Desktop Log in as user
piat the graphical desktop
- Enable Camera > Enable
- Advanced Options > SSH > Enable
- After the Pi reboots to a desktop follow these instructions on how to use the GUI tool to configure your Wi-Fi network
- Make note of the IP address the Pi reports when it connects to your network. This will be used to SSH to the Pi in later steps to configure the Pi and retrieve your finished video. The steps below for configuring the Pi are easier done from an SSH session to the Pi as well.
Install the UV4L Raspicam System
The Raspberry Pi camera module does not present inside the Raspbian Linux OS like standard USB video cameras. Most applications that use video under Linux access the camera using the Video for Linux or V4L driver system. The V4L system is typically created through kernel level drivers which create a /dev/video0 device. There are no kernel level V4L drivers for the Pi camera module however there are user space drivers or UV4L drivers that will create the V4L style device for standard Linux video applications to access.
Follow the instructions below to download and install the UV4L package for the Raspberry Pi camera.
Open an SSH connection to you Pi to execute the lines below. It will make it easier to copy and paste them than trying to type them at the console.
wget http://www.linux-projects.org/listing/uv4l_repo/lrkey.asc && sudo apt-key add ./lrkey.asc sudo sh -c 'echo "deb http://www.linux-projects.org/listing/uv4l_repo/raspbian/ wheezy main" >> /etc/apt/sources.list' sudo apt-get update sudo apt-get install uv4l uv4l-raspicam uv4l-raspicam-extras
These commands will add the repository to your Pi and install the package. It will also setup the driver to run at boot time.
The raspicam has a habit of creating a full screen preview of the camera view when the camera is accessed. Unfortunately this behavior will obscure the apps that you are trying to use on the screen, so the next step is to disable this preview. Disabling the preview will take a little surgery to the script that launches the UV4L driver.
- Edit the file:
- Find the line below
$UV4L --syslog-host localhost -k --sched-rr --auto-video_nr --driver raspicam --encoding mjpeg
--nopreivew yesto the end of the line so it looks like the line below
$UV4L --syslog-host localhost -k --sched-rr --auto-video_nr --driver raspicam --encoding mjpeg --nopreview yes
- Save the file and reboot your Pi with the following command
Install stopmotion Software and Test
The remaining steps can be done from the console of you Raspberry Pi.
- Open a terminal window by double-clicking on the LXTerminal icon.
- Execute the command
sudo apt-get install stopmotion
Setup The Stage and Camera
Setup your scene for your adventure.
- Choose a well lit location and add lamps as needed to allow for a nice bright stage
- Build the scene for your first picture
- Launch stopmotion with the command
- Click the video icon to start the video feed and aim your camera
- Use the live video feed preview to angle your camera for the shoot
Record the Adventure
- Move the Number of images silder to 1. This is the number of previous pictures that stopmotion mixes together in the preview pane.
The Pi does not have enough horsepower to mix multiple layers of images smoothly. As you capture images, the preview window will lightly overlap the last image over the live preview.
The onion skin overlay of the last image taken will allow you to make fine adjustments and see the new frame compared to the last one before you take the picture.
The video preview is noticeably laggy but it was entirely usable and actually helped me make slow purposeful changes.
- Click on the camera icon indicated in the image above to add frames to your video
- Continue making adjustments to your scene and adding frames to your video, moving the figures slightly between each frame
- Save your work often with the File > Save menu option
Export and Retrieve the Video
Once you are happy that you have completed a scene, you can export it into a video and retrieve it from the Pi. The scene can then be incorporated into your larger work with a more robust video editing package like iMovie.
- Export the video with the File > Export menu option. Make sure to add a .avi extension to the movie name that you export. Without the extension the software does not know which way you wish to encode the video
- Copy the video from your Pi using the scp command line or a GUI scp client of your choice
- Add the scene to your epic movie, add audio and any after effects to make it truly awesome
I think my video needs some sea sounds and an awesome soundtrack and it will be ready for the big screen.
In this tutorial I have show you how to build and operate a stop motion animation studio with your Raspberry Pi and created an animated movie scene. I showed you how to configure the Raspberry Pi camera to be used by standard Linux video applications like stopmotion.
I also showed how to replace the short camera cable and mount the camera module to make using it easier and more flexible. I also demonstrated how to create a stop motion video scene to incorporate into your next project. I hope you enjoy experimenting and creating videos with your new animation station.