2019-05-01_Linux_Format

(singke) #1

http://www.techradar.com/pro/linux May 2019LXF249 55


Stop-motion animation TuTorialS


Don’t have a
suitable tripod
for overheard
work? Build your
own rostrum
with Meccano
or another
construction toy.

For the best results, use a smartphone tripod to mount your Raspberry
Pi for improved stability in your stop-motion movie.

KeePsteadYandcaRRYon


Lights!
To turn your Raspberry Pi into the central component of
your stop-motion studio, you’ll need to attach a camera.
While USB cameras work fine, it’s far more satisfying to
employ the latest Raspberry Pi Camera Module.
Connecting this device to the Raspberry Pi requires
you to insert the ribbon cable into the ‘Camera’
connector on the SBC. If you’re using a Raspberry Pi
model B, the shiny side of the ribbon should face away
from the Ethernet port.
For Raspberry Pi Zero devices with a camera port,
the shiny side of the ribbon should face up. Take care to
correctly unclip the catch on these connectors before
inserting the ribbon. Similarly, ensure the catch is
correctly secured afterwards.
Boot up the Pi and enter the configuration screen on
the desktop (Menu > Preferences > Raspberry Pi
Configuration) or open a terminal and enter sudo raspi-
config. Here, select Interfaces (or Interfacing Options
in the terminal), then enable Camera. Click OK to
confirm and restart your Pi.
With the Pi restarted, open a terminal window, and
enter raspistill -o image1.jpg. This should take a photo
from the camera, confirming the device is correctly
connected and working. You’ll notice that raspistill is
built into the Raspbian operating system. It’s part of the
raspicam software, which we’ll come back to later.


Camera!
Setting up the camera on your Raspberry Pi will let you
create a stop-motion video, but it can be a bit fiddly
entering the same command for every single shot. The
solution? Create a shutter button that you can connect
to your Raspberry Pi!
Prototype it first using a breadboard, connecting the
two wires to pins 6 and 11 on the GPIO header (or GND
and GPIO17). With the button correctly mounted to
connect to the wires, you can use this setup to capture
each frame. Alternatively, connect a wired-up button
directly to the pins on your Raspberry Pi’s GPIO.
However you connect the shutter button, you’ll then
need to create a Python script to detect it. Each push of
the button will capture and save a new photo to the
specified directory. Open Menu > Programming >
Python 3 (IDLE) then File > New. In the resulting
window, input this script, from raspberrypi.org
(http://bit.ly/LXF249-stopmotion-script):


from picamera import PiCamera
from time import sleep
from gpiozero import Button

button = Button(17)
camera = PiCamera()

camera.start_preview()
frame = 1
while True:
try:
button.wait_for_press()
camera.capture(‘/home/pi/Pictures/stopmotion/
frame%03d.jpg’ % frame)
frame += 1
except KeyboardInterrupt:
camera.stop_preview()
break
This script uses the PiCamera, sleep and Button
programs, from the picamera, time and gpiozero
libraries. It defines a button (pin 17) and camera and
waits for a button press.
At this point, it adds a single image into the specified
directory. The script ends only when a keyboard
interrupt command is detected.

One important element to keep in mind is stability: it’s all too easy
to knock a camera, especially one mounted on a tripod. An overhead
camera can also be subject to vibrations and wobbles.
The result of these bumps can be a jarring distortion in your
finished movie. While repeating the shot is one solution, it can be
time-consuming to arrange. A better solution is to ensure that the
camera is secured to a sturdy piece of gear.
A tripod should have a heavy, reliable base with a low centre of
gravity to avoid topples. An overhead camera should be securely
connected to the base, or whatever rigging is being used to support
it. You need to minimise any vibrations that might occur during the
capturing of your stop-motion frames. This can be difficult using the
breadboard-based shutter button, so it’s worth changing this to a
direct GPIO pin connection with a long cable.
For this project we opted to use a Raspberry Pi case with a
mounting point for the camera module. This meant we could use the
Pi itself like a camera, positioning it using a smartphone tripod. You
might opt to connect the Pi to a car-windscreen-mounted
smartphone holder for similar vibration-free stop-motion video.

linux, onePage at a time Subscribe now at http://bit.ly/LinuxFormat


Finding
somethingto
animateinyour
stop-motion
movieproject
mightseem
tough,but
reallyyoucan
useanything.
it couldbe
household
objects,orit
mightbetoys.
checktoyshops
forPlasticine
characterkits
orlegopacks
specifically
designedfor
stop-motion
projects.
Free download pdf