THE OFFICIAL RASPBERRY PI
CAMERA
GUIDE
FOR CAMERA MODULE & HIGH QUALITY CAMERA
2
THE OFFICIAL RASPBERRY PI CAMERA GUIDE
3
THE OFFICIAL RASPBERRY PI CAMERA GUIDE
First published in 2020 by Raspberry Pi Trading Ltd, Maurice Wilkes Building,
St. John's Innovation Park, Cowley Road, Cambridge, CB4 0DS
Publishing Director: Russell Barnes • Editor: Phil King
Contributors: Dan Aldred, Wesley Archer, Jody Carter, PJ Evans,
Richard Hayler & family, James Singleton, Rob Zwetsloot,
the Raspberry Pi Foundation Education Team
Design: Critical Media
CEO: Eben Upton
ISBN: 978-1-912047-52-9
The publisher and contributors accept no responsibility in respect of any omissions
or errors relating to goods, products or services referred to or advertised in this book.
Except where otherwise noted, the content of this book is licensed under a Creative
Commons Attribution-NonCommercial-ShareAlike 3.0 Unported
(CC BY-NC-SA 3.0)
4
THE OFFICIAL RASPBERRY PI CAMERA GUIDE
Welcome to
The Official Raspberry
Pi Camera Guide
O ne of the most popular add-ons for the Raspberry Pi, the official Camera Module –
or the new High Quality Camera – turns your favourite single-board computer into
a powerful digital camera. Launched back in 2013, the original Camera Module was
succeeded by the higher-spec v2 in April 2016. The High Quality Camera was launched in April
2020, offers Ultra HD image resolution, and enables you to attach any C- or CS-mount lens.
In this book we’ll show you how to get started with your Raspberry Pi camera, taking photos
and videos from the command line and writing Python programs to automate the process.
We’ll reveal how to create time-lapse and slow-motion videos, before moving on to exciting
projects including a Minecraft photo booth, wildlife camera trap, and smart door with video.
There are just so many things you can do with a Raspberry Pi camera!
Phil King, Editor
5
THE OFFICIAL RASPBERRY PI CAMERA GUIDE
Contents
Chapter 1: Getting started
Set up and connect your camera and start taking shots
Chapter 2: Precise camera control
Use command-line switches to access camera options and effects
Chapter 3: Time-lapse photography
Take photos at regular intervals, then turn the images into a video
Chapter 4: High-speed photography
Film dazzling slow-motion clips of exciting events
Chapter 5: Control the camera from Python
Use the picamera library to access the camera in Python programs
Chapter 6: Stop-motion and selfies
Wire up a physical push-button to take photos
Chapter 7: Flash photography using an LED
Add an LED flash to shoot images in low light
Chapter 8: Make a Minecraft photo booth
Build a booth in Minecraft that takes photos of the real world
6
008
016
020
024
028
034
040
046
THE OFFICIAL RASPBERRY PI CAMERA GUIDE
Chapter 9: Make a spy camera
Set up a motion-activated spy camera in your room
Chapter 10: Smart door
See who’s at the door and know when the post has arrived
Chapter 11: Car Spy Pi
Use ANPR to identify who’s parked on your driveway
Chapter 12: Build a wildlife camera trap
Detect and photograph animals in your back garden
Chapter 13: Take your camera underwater
Explore the underwater world with your Raspberry Pi and camera
Chapter 14: Install a bird box camera
Observe nesting birds without disturbing them
Chapter 15: Live-stream video and stills
Stream video and regular stills to a remote computer
Chapter 16: Set up a security camera
Protect your home from intruders using motionEyeOS
Chapter 17: Quick reference
A guide to the camera hardware, commands, and picamera Python library
050
054
062
070
076
086
092
102
108
7
THE OFFICIAL RASPBERRY PI CAMERA GUIDE
Chapter 1
Getting started
Find out how to connect your High Quality Camera or
Camera Module, enable it, and take your first shots
video. Let’s get started…
to your Raspberry Pi using the supplied ribbon cable. We will then enable it in Raspbian,
before entering some commands in a Terminal window to start shooting photos and
I n this chapter, we show you how to connect the High Quality Camera or Camera Module
01. High Quality Camera
The High Quality Camera (HQ Camera for short) can capture higher-resolution images than
the standard Camera Module. Unlike the latter, it doesn’t have a lens already attached.
Instead, it can be used with any standard C- or CS-mount lens; 6 mm and 16 mm lenses are
available to purchase with the camera to help you get started.
6 mm CS-mount lens
A low-cost 6 mm lens is available for the
HQ Camera. This lens is suitable for basic
photography. It can also be used for macro
photography because it can focus objects at
very short distances.
8
THE OFFICIAL RASPBERRY PI CAMERA GUIDE