Snapshot
The amazing Raspberry Pi camera module opens into a whole new world of useful projects. We'll show you how to use the Pi camera for time-lapse photography, and we'll even help you set up a motion-detecting surveillance camera.
The amazing Raspberry Pi camera module opens into a whole new world of useful projects. We'll show you how to use the Pi camera for time-lapse photography, and we'll even help you set up a motion-detecting surveillance camera.
The Raspberry Pi has seen a number of fantastic improvements since its original release in April 2012, including a new PCB layout, new mounting holes, and a RAM upgrade to 512MB. Following these improvements was the introduction of the low-price model A Raspberry Pi, which was intended as a cheaper model for education and applications that require lower power. Then, in May 2013 (just over a year after the initial release of the model B Raspberry Pi) and after some slight delays, the Raspberry Pi Foundation officially released its first add-on board: the Raspberry Pi camera module (Figure 1).
Before the camera module, it was of course possible to access a camera feed on the Raspberry Pi using a suitable webcam. Camera functionality had already worked its way into a variety of projects, from live weather monitoring to robotics. However, the clever folks at the Raspberry Pi Foundation were aware of the fact that, if the highly enthusiastic Raspberry Pi community would repurpose their existing webcams, an add-on camera module stood a strong chance of success.
The camera module, designed specifically for the Raspberry Pi boards, brought with it a fair number of features that make it superior to many sophisticated webcams on the market (see the box titled "Camera Specs").
It is easy to see why this camera is now the preferred choice for almost every application that requires a dedicated camera for still photography or video capture with the Raspberry Pi.
This article will guide you through the process of setting up and using the Raspberry Pi camera module.
Camera Specs
To attach the camera module to the Raspberry Pi, first make sure your Raspberry Pi is completely disconnected from any power source. Before removing the camera module from its grey anti-static bag, make sure you touch a radiator, a tap, or any other grounded metal object to get rid of any static that you might have built up. (The camera module is fairly sensitive and static electricity can actually damage it.)
The camera board CSI connector is located between the Ethernet and HDMI ports on the Model B Raspberry Pi. The Ethernet port does not exist on a Model A board, but the camera connector is in the same place.
Open the connector by pulling the tabs on either side of the connector upwards and towards the Ethernet port. You should then be able to insert the ribbon cable on the camera module (with silver connectors facing towards the HDMI port) into the connector. Hold the cable firmly in place, and close the CSI connector by pushing the top part towards the HDMI port and down. It should click into place nicely and hold the camera ribbon cable securely. To avoid damage, take care not to bend the ribbon cable at too much of an angle. Figure 2 shows a picture of the camera module connected to the Raspberry Pi.
Next, you need to power up the Raspberry Pi and log in to Raspbian. The camera module options were not available in early versions of Raspbian, so to start with, you need to make sure that Raspbian is completely up to date. In a terminal window, type:
$ sudo apt-get update $ sudo apt-get upgrade
These commands might take a few minutes. Updating your system will ensure you have a version of the raspi-config module with support for the Raspberry Pi camera. Now, you can start raspi-config with the command:
$ sudo raspi-config
You will see a screen that looks like Figure 3.
Use the keyboard to move down to the camera option, then hit enter. The following screens ask you to confirm and reboot. Once you reboot, the camera module will be enabled and ready to start snapping pictures!
Now that you have the camera module enabled, I bet you are wondering how you can start taking pictures and videos with it? Again, this is quite a simple process that can be done either from the terminal or within a program.
The basic commands are raspivid
and raspistill
, which (as the names suggest) are for capturing video and still images, respectively. Each of these commands can accept a number of parameters after them. Several parameters are available, but the most basic are:
-o
or -output
, for setting the output filename-t
or -timeout
, for setting the time in milliseconds for which a preview will display (the default is 5 seconds, and when using raspistill
, it will capture the last frame of the preview and save it to the specified filename. When using raspivid
, the -t
parameter defines the capture time.)Therefore, to display a 5 second preview and then save a jpeg picture called test.jpeg
, the command would be:
$ raspistill -o test.jpeg
To take a 30-second video and save it in h264 format, use the command:
$ raspivid -o test.h264 -t 30000
for a list of other parameters, type either of the following commands:
$ raspistill | less $ raspivid | less
Have a play with all of these settings and see how they change the picture (Figure 4). You'll find that the little camera is quite powerful. If you want to take a video that cycles through all the available image modes, you can append -d
or -demo
to the end of the raspivid
command. See the Raspberry Pi Foundation's camera documentation for an in-depth look at all of the functionality available from the camera module [2].
Pages: 2
Price $15.99
(incl. VAT)