Copyright 2018 Sandy Antunes and James West. All rights reserved.
Published by
Maker Media, Inc.
1700 Montgomery Street, Suite 240
San Francisco, CA 94111
Maker Media books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (safaribooksonline.com). For more information, contact our corporate/institutional sales department: 800-998-9938 or corporate@oreilly.com.
Publisher: Roger Stewart
Editor: Patrick DiJusto
Copy Editor: Elizabeth Welch
Proofreader: Scout Festa
Interior and Cover Designer: Maureen Forys, Happenstance Type-O-Rama
October 2018: First Edition
Revision History for the First Edition
2018-10-08 First Release
See oreilly.com/catalog/errata.csp?isbn=9781680455427 for release details.
Make:, Maker Shed, and Maker Faire are registered trademarks of Maker Media, Inc. The Maker Media logo is a trademark of Maker Media, Inc. Jumpstarting Raspberry Pi Vision and related trade dress are trademarks of Maker Media, Inc. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and Maker Media, Inc. was aware of a trademark claim, the designations have been printed in caps or initial caps. While the publisher and the author have used good faith efforts to ensure that the information and instructions contained in this work are accurate, the publisher and the author disclaim all responsibility for errors or omissions, including without limitation responsibility for damages resulting from the use of or reliance on this work. Use of the information and instructions contained in this work is at your own risk. If any code samples or other technology this work contains or describes is subject to open source licenses or the intellectual property rights of others, it is your responsibility to ensure that your use thereof complies with such licenses and/or rights.
978-1-680-45542-7
Safari Books Online
Safari Books Online is an on-demand digital library that delivers expert content in both book and video form from the worlds leading authors in technology and business. Technology professionals, software developers, web designers, and business and creative professionals use Safari Books Online as their primary resource for research, problem solving, learning, and certification training. Safari Books Online offers a range of plans and pricing for enterprise, government, education, and individuals. Members have access to thousands of books, training videos, and prepublication manuscripts in one fully searchable database from publishers like OReilly Media, Prentice Hall Professional, Addison-Wesley Professional, Microsoft Press, Sams, Que, Peachpit Press, Focal Press, Cisco Press, John Wiley & Sons, Syngress, Morgan Kaufmann, IBM Redbooks, Packt, Adobe Press, FT Press, Apress, Manning, New Riders, McGraw-Hill, Jones & Bartlett, Course Technology, and hundreds more. For more information about Safari Books Online, please visit us online.
How to Contact Us
Please address comments and questions to the publisher:
Maker Media, Inc.
1700 Montgomery Street, Suite 240
San Francisco, CA 94111
You can send comments and questions to us by email at books@makermedia.com .
Maker Media unites, inspires, informs, and entertains a growing community of resourceful people who undertake amazing projects in their backyards, basements, and garages. Maker Media celebrates your right to tweak, hack, and bend any Technology to your will. The Maker Media audience continues to be a growing culture and community that believes in bettering ourselves, our environment, our educational systemour entire world. This is much more than an audience, its a worldwide movement that Maker Media is leading. We call it the Maker Movement.
To learn more about Make: visit us atmake.co.
Preface
I f a camera takes a picture and no one notices, did it really happen? In this book, were going to show you how to make a working Raspberry Pibased camera system so that you can capture time-lapse images and view via WiFi, trigger the camera if motion is detected, and even carry out basic facial recognition as an introduction to machine learning methods.
Take a Raspberry Pi and add a camera module, and you have a programmable camera. Add some software, and you can start to do interesting surveillance and automatic object recognition work with it. Activate the Pi as a WiFi node and you can do all these wonderful things from a distance.
A good surveillance system does more than take pictures. It should also turn those pictures into actionable information that increases your knowledge. Thats now easily done in software, and were going to show you how.
This book pulls together a set of little trickssetting up Pi cameras, making a Pi broadcast as a WiFi device, adding time lapse and motion detection and face recognition, and sticking a battery pack on it so it can function anywhereto create portable spy cameras. Weve used these rigs in everything from Find the Pi party contests, to implementing privacy-respecting security in our lab, to showing off modern tech like facial recognition. Other uses could include monitoring deer and wildlife, checking your house mailbox for mail arrival, and capturing time-lapse sequences of natural events or traffic patterns.
Our first project will be to create a portable SpyPi camera rig that broadcasts images via WiFi without needing a networkyou just have to log into it to see what the camera sees . Its great for a find the camera hunting challenge or stand-alone security.
The second project will involve setting up a time-lapse camera that can do simple motion detectionperfect for monitoring a location. The system will include automatic deletion of old images after a week.
The third project will be to add facial detection and facial recognition to your SpyPi. In the process, youll learn about the tools and software installed by the end of these projects so that you can go beyond this book and explore additional machine learning methods.
So grab a Pi, an SD card, a USB camera, and a USB battery pack, and lets go!
Chapter 1
Introduction to the Raspberry Pi
In this book, we will be discussing how to take a Raspberry Pi and turn it into a do-it-yourself security system. The following chapters will cover projects ranging from taking time-lapse photos to using facial recognition. Before we get to any of those, though, we need to spend some time preparing the Pi so that its ready for those projects.
These setup processes may not be the most exciting information covered in this book, but they are arguably the most crucial for you to know. The Raspberry Pi is a versatile device, providing a good base for a variety of projects. It is for that very reason that knowing how to modify and customize your Pi to suit a given project is critical.
This chapter will cover, among other things, how to install software packages and connect to your Pi remotely. This knowledge is useful in any Pi project and helps open up possibilities for taking your projects further.
Figure 1-1: Raspberry Pi 3 with USB webcam
Next page