Stop-motion animation

Lead Image © kudryashka, 123RF.com

Lights, Camera, Action

Stop-motion animation doesn't require expensive cameras and movie editing software. With Scratch and a Pi camera, you can become your own director, producer, and publisher.

When you combine Scratch, the GPIO server, and the Pi Camera, you get a simple platform for making stop-motion animations or movies. This project involves some programming, but much of the creative work is in creating a story and then producing that story in a way that you can play back using Scratch.

To create a stop-motion animation, you create a video set using movable dolls, clay models, Lego figures, or anything that can be moved in subtle ways. You move the characters in very small increments, and after each move, you capture a picture, which is known as a frame. When putting together my script, I used two Lego mini-figures on a 32x32 Lego base. The characters walk toward each other on a collision course. If you need Lego-based inspiration, you can search YouTube for "brick film."

Taking the Shot

Figure 1 shows the script to capture the photos. I'm using the Pi Camera, which is available to Scratch through the GPIO server starting with the Raspbian Jessie release.

Figure 1: The project initialization script to enable the Scratch GPIO server and take photos.

In addition to turning the GPIO server on, this initialization script uses the button click on a PicoBoard to control when to take picture. I'm using the button on the PicoBoard because I have the board available, so it's convenient. The sensor(button pressed)? block value is included with Scratch, and as long as a PicoBoard is connected, it can sense the state of the button.

If you don't have a PicoBoard, another add-on device, such as the PiBrella would work, or you could wire up your own button using the Raspberry Pi's GPIO pins. Of course, you do not need an add-on device or button to take photos with the Pi camera. You can use another event within Scratch to control when the camera captures a photo, such as a key press or a sprite click.

The broadcast(photo) block is the command that will take a photo with the attached Pi Camera. That photo will be added as a costume, as seen in Figure 2, which shows the first couple of frames in my walking figure animation.

Figure 2: A snippet showing two frames. Each costume thumbnail contains a number, a name, and a file size.

In Figure 2, you see several key bits of information about the photos taken. Each new photo is sequentially added to the list of costumes, with a physical position number. You'll use this value later. You can also see that each photo is imported into Scratch at a size of 320x240 pixels, which is smaller than the stage.

If you want the image to take up the entire stage, you could increase the size of the sprite (and therefore, its costumes) by 150 percent using the set size to(150)% block. That will distort the image, however.

If you add this script to the stage, the captured photos are added as backgrounds, which automatically fill the size of the stage. I chose to use sprite costumes so that I could create more than one animation in a single project by having more than one sprite; you can't add more than one stage.

Frame the Shot

After you get the programming in place to capture the photos, it's time to think about your scene and how you will photograph it. In this project, this might be one of the more challenging aspects, but here are a few tips I learned as I experimented with stop motion.

  • Use a background to block out the surrounding environment. This can be something you create specifically for the movie, such as a drawing, or it can be a sheet of a solid color. I used a blanket.
  • Add lighting to the scene. Natural light and the light in your room will often be insufficient. The Pi Camera does not have a flash, so the more detail you can expose with the lighting, the better. I used a Halogen shop light on a tripod.
  • Make small movements. Consider that taking one step with a mini-figure might take four or more frames. Small movements create more frames, which makes for a higher quality animation.
  • If something can move accidentally, tape it down. This also applies to your Pi and the camera. Any unexpected movements of characters, the camera, or the scene will be noticeable.
  • Pick a perspective for the shot. I shot my scene straight on and at the same perspective as the action, but you could position your camera for an aerial shot.

You can fine-tune the positioning of the characters, backgrounds, and camera by previewing the shot in Scratch. Scratch can use a computer's webcam, and with the Pi camera attached, the webcam feature pulls the image from the Pi camera. To access the webcam, click on the Costumes tab and then click on the Camera button. A new window will open with a live preview of what your camera sees. After your scene looks acceptable to you, click the Done button to close the webcam preview.

At approximately eight inches from the front of the camera, I was able to film a width of approximately 10 inches using the Pi camera, so that's a relatively compact space in which to work, but still sufficient for the project.

Buy this article as PDF

Express-Checkout as PDF

Pages: 4

Price $2.95
(incl. VAT)

Buy Raspberry Pi Geek

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content