Make a motion-sensing camera with the Raspberry Pi
Posted on 25 Dec 2013 at 12:00
Gareth Halfacree reveals how to use a Raspberry Pi to make a wildlife camera
The low-cost Raspberry Pi microcomputer made headlines earlier this year when the Zoological Society of London and the Kenya Wildlife Service joined forces to produce a network of remote cameras to monitor animals and catch poachers.
Although it’s unlikely poachers are a problem in your garden, you can use the same technology to keep an eye on the comings and goings of wildlife in your back yard – albeit with rather more footage of squirrels, and fewer lions.
If you haven’t used a Raspberry Pi before, you’ll need to install the Raspbian OS to your SD card and make sure it’s up to date.
What you'll needFor this project, you'll need:
- a Raspberry Pi Model A or Model B
- a Raspberry Pi camera module
- a case with a camera mount
- an SD card with an up-to-date Raspbian installation
- a monitor, keyboard and network connection to set up the software
The first step is to attach the Raspberry Pi Camera Module into the Camera Serial Interface (CSI) port on the top of the Raspberry Pi. This small slot-like port is found on the bottom right of the board’s top surface, between the HDMI port and the Ethernet port.
Pull the tab gently up, then push the bare end of the Camera Module’s ribbon cable into the slot, with the silver contacts on the cable facing towards the left of the board. When the cable is at the bottom of the slot, hold it in place with one hand while pushing the tab back down with the other hand to secure it in place.
Connect the Pi to a monitor, keyboard and network with internet access. If you have a Model A, you’ll need to use a USB to Ethernet or Wi-Fi dongle in order to download the required software, but this can be removed when the camera is in use.
When the Pi has booted, log in using the “pi” account and load the Raspberry Pi Software Configuration Tool by typing:
Scroll down the list to the Enable Camera option and select it with the Enter key. Choose “Enable” in the menu that appears, then choose Finish and then Yes when asked to reboot.
When the Pi has rebooted, log in and install the software that will drive the motion-sensing camera – a Python module for performing image analysis and manipulation, plus a tool for keeping the script running – by typing:
sudo apt-get install python-
Then download the PiCam Python script, which has been developed by Raspberry Pi community members and shared on the official forums:
Finally, create a directory for the script to store its images:
With the software installed, you can disconnect your Pi from the network and position it ready to capture images. To run the capture software, first make it executable by typing:
chmod +x picam.py
Then run it by typing:
The Python script works by continuously taking low-resolution images, and comparing them to one another for changes caused by something moving in the camera’s field of vision. When a change is detected, the camera takes a higher-resolution snapshot and then goes back to look for changes.
The software can need fine-tuning, especially if you place it close to plants, which can move in the wind: open the script in a text editor and experiment with the various options in order to adjust sensitivity or remove areas from being analysed.
Images captured are placed in the “picam” folder (only the higher-resolution images; the lo-res images are discarded). To stop the script, press Ctrl+C on the keyboard.
If you’re placing your camera in an inaccessible location, you can use a wireless network dongle to control it over the network. Find your Pi’s IP address by typing:
Connect to this address using an SSH client such as PuTTY for Windows, and run the script using the Screen utility to prevent it from closing when you disconnect:
Since the Pi is low power, you can truly untether it by connecting it to a battery pack, which can be charged using solar power.
Combined with a waterproof case, such as the PiCE from Elson Designs, it’s possible to turn the humble Pi into a powerful wildlife camera that can take extremely impressive images – even in urban gardens.
Author: Gareth Halfacree
For more details about purchasing this feature and/or images for editorial usage, please contact Jasmine Samra on firstname.lastname@example.org
- What is Google Inbox?
- Windows 10 release date, features and how to get the Technical Preview
- Google announces the Nexus 6, Nexus 9 and the arrival of Android Lollipop
- Lenovo and Ashton Kutcher launch Yoga Tablet 2 Pro, Yoga Tablet 2 and Yoga 3 Pro
- Lenovo Yoga event live stream: watch Ashton Kutcher's tablet launch live
- HTC shows off Desire Eye selfie phone and periscope-like camera
- Xim: the slideshow app to get excited about
- Adobe has more apps for iOS, but none for Android
- How to download and install Windows 10 Technical Preview
- iPhone 6 Plus "less likely to bend than HTC One"
- Google Glass: mugger bait, pub problem and other lessons learned from two dangerous weeks
- Twitter, please don't fiddle with my feed
- How Satya Nadella can get some pay-raise karma
- Windows 10: a step back to go forward
- Michael Dell: Cloud infrastructure is the roads, bridges and highways of the 21st century
- How to check your identity hasn’t been sold to the hackers
- Tim Cook: this is how much TV has changed since the 70s
- Westminster wins the .London battle
- 20 years of PC Pro: from deep pan pizza to virtualisation
- Five reasons why the Apple Watch leaves me cold