Question 1.18: You want to use the Raspberry Pi camera module (see “Modules......

You want to use the Raspberry Pi camera module (see “Modules” on page 381).

Table A-8. Modules
Raspberry Pi camera module Adafruit: 1367, MCM: 28-17733, CPC: SC13023
Arduino Uno SparkFun: DEV-11021, Adafruit: 50, CPC: A000066
Level converter, four-way SparkFun: BOB-11978, Adafruit: 757
Level converter eight-way Adafruit: 395
LiPo boost converter/charger SparkFun: PRT-11231
PowerSwitch tail Adafruit: 268
16-channel servo controller Adafruit: 815
Motor driver 1A dual SparkFun: ROB-09457
RaspiRobot board Sparkfun: KIT-11561, raspirobot.com
PiFace digital interface board MCM: 83-14472, CPC: SC12827
Humble Pi MCM: 83-14637, CPC: SC12871
Pi Plate Adafruit: 801
Gertboard MCM: 83-14460, CPC: SC12828
Breakout board with paddle terminals MCM: 83-14876, CPC: SC12885
PIR motion detector Adafruit: 189
Venus GPS module SparkFun: GPS-11058
Methane sensor SparkFun: SEN-09404
Gas sensor breakout board SparkFun: BOB-08891
ADXL335 triple-axis accelerometer Adafruit: 163
4×7-segment LED with I2C backpack Adafruit: 878
Bicolor LED square-pixel matrix with I2C backpack Adafruit: 902
PiLite interface board Ciseco, CPC: SC13018
aLaMode interface board Makershed: MKWY1, Seeedstudio: ARD10251P
Freetronics Arduino LCD shield www.freetronics.com
RTC module Adafruit: 264
16 x 2 HD44780 compatible LCD module SparkFun: LCD-00255, Adafruit: 181
Step-by-Step
The 'Blue Check Mark' means that this solution was answered by an expert.
Learn more on how do we answer questions.

The Raspberry Pi camera module (Figure 1-17) is attached to a Raspberry Pi by a ribbon cable.

This cable attaches to a special connector just behind the Ethernet socket. To fit it, pull up the levers on either side of the connector, so that they unlock, and then press the cable into the slot with the connector pads of the cable facing away from the Ethernet socket. Press the two levers of the connector back down to lock the cable in place (Figure 1-18).

The camera module packaging states that it is sensitive to static. So, before handling it, ground yourself by touching something grounded like the metal case of a PC.

The camera module requires some software configuration. The easiest way to configure it is to use raspi_config (Recipe 1.12). To run raspi-config, enter the following command into a Terminal session.

$ sudo raspi-config

You will then see a list of options like those shown in Figure 1-19.

If the option Camera is not in the list, then you need to update the operating system by running the following commands in a Terminal session (see Recipe 3.2):

$ sudo apt-get update
$ sudo apt-get upgrade

You need an Internet connection to do this. The second of these commands may take a few minutes to complete. When they are complete, reboot your Raspberry Pi (Recipe 1.17).

Now, when you run raspi-config you will see the option to enable the camera (Figure 1-20).

Two commands are available for capturing still images and videos: raspiStill and raspivid.

To capture a single still image, use the raspiStill command as shown here:

$ raspistill -o image1.jpg

A preview screen displays for about five seconds and then takes a photograph and stores it in the file image1.jpg in the current directory.

To capture video, use the command raspivid:

$ raspivid -o video.h264 -t 10000

The number on the end is the recording duration in milliseconds—in this case, 10 seconds.

Discussion

Both raspstill and raspivid have a large number of options. If you type either command without any parameters, help text displays options that are available.

The camera module is capable of high-resolution stills and video recording.

Here are some of the key features of the camera:

• 5-megapixel sensor

• Fixed focus f/2 lens

• Still resolution 1,920×1,080

• Video 1080p 30fps

An alternative to the camera module is to use a USB webcam (see Recipe 4.5).

See Also

The RaspiCam documentation includes raspstill and raspivid.

1.17
1.18
1.19
1.20

Related Answered Questions

Question: 1.17

Verified Answer:

Click on the red Logout button in the bottom-right...
Question: 1.15

Verified Answer:

You can use the raspi-config tool to change your p...
Question: 1.14

Verified Answer:

You can increase the clock frequency of a Raspberr...
Question: 1.10

Verified Answer:

Many people have been caught out by this problem. ...
Question: 1.9

Verified Answer:

Unless you are embedding your Raspberry Pi in a pr...