Maximum PC - USA (2019-06)

(Antfer) #1
inserting the ribbon. Similarly, ensure the catch is correctly
secured afterward.
>> 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.

3


CAMERA!
Setting up the camera on your Raspberry Pi will enable
you to create a stop-motion video, but it can be a bit
awkward 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)
[Image C]. 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 Raspberr y
Pi’s GPIO.
>> However you connect the shutter button, you then need
to create a Python script to detect it. Each push of the button
captures and saves 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/2IJeu6q):
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.

4


ACTION!
With everything set up, it’s time to make your movie. This
could be considered as the difficult stage, depending on
how much planning you’ve done (you have made a storyboard,
haven’t you?).
>> In truth, however, if the Raspberry Pi is securely positioned,
with a reliable power supply, and the shutter button correctly
connected, you shouldn’t have any trouble. The worst that’s

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
center 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 also need to
minimize 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-windshield-mounted smartphone holder for similar
vibration-free stop-motion video.

KEEP STEADY AND


CARRY ON


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

Don’t have a suitable tripod for
overhead work? Build your own
rostrum with a construction toy.

maximumpc.com JUN 2019 MAXIMUMPC 57

Free download pdf