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.
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."
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.
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.
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.
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.
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.
Pages: 4
Price $15.99
(incl. VAT)