How to Test the Raspberry Pi Camera Module
Connecting a Raspberry Pi Camera Module is the first step. Once you have connected your Raspberry Pi Camera Module, it’s a good idea to test whether it’s working correctly.
Make sure the camera is enabled: Go into the Raspberry Pi Configuration tool, click Interfaces, and select Enabled beside the Camera option.
Let’s test the camera from the command line interface. Click the Terminal icon at the top of the screen to start. It has a
>_ symbol on it. To take a still photo, type in this command:
raspistill -o testshot.jpg
You should see what the camera sees onscreen for a moment before it takes the picture. You can verify that the image was created by looking at the files in your directory with this command:
You can use lots of different options to take still photos, too. This example takes a shot with the pastel filter and flips the picture horizontally (
-hf) and vertically (
raspistill -ifx pastel -hf -vf -o testshot2.jpg
All those hyphens and letter combinations might seem a bit random to you now, but once you have learned a little more, they should make more sense. To see the documentation for
raspistill 2>&1 | less
Use the down-arrow key to move through the information, and press Q to finish.
Your photos are stored in your
pi directory. Use the File Manager to find your files and Image Viewer to see them.
To shoot video, you use
raspivid. Enter this command to shoot a 5-second film:
raspivid -o testvideo.h264 -t 5000
You can view the video you made using
The video footage is captured as a raw H264 video stream. For greater compatibility with media players, it’s a good idea to convert it to an MP4 file. Start by installing MP4box using this command:
sudo apt-get install gpac
Then you can convert your video file (called
testvideo.h264) into an MP4 file (called
testvideo.mp4) like this:
MP4Box -add testvideo.h264 testvideo.mp4
You can get help on using
raspivid 2>&1 | less
There is also a library you can use in Python to access the camera from your own Python programs. See the documentation for more information on using the Raspberry Pi Camera Module.