How to install and use the Raspberry Pi Camera Module
In this step by step guide we will explain how to install the Raspberry Pi Camera Module, along with how to take pictures and videos with it.
Camera Module Hardware Installation
Before you take your Camera Module out of the box, be aware that it can be damaged by static electricity. Make sure you have discharged yourself by touching an earthed object (e.g. a radiator, PC Chassis or similar).
Install the Raspberry Pi Camera module by inserting the cable into the Raspberry Pi camera port. The cable slots into the connector situated between the USB and micro-HDMI ports, with the silver connectors facing the micro-HDMI ports.
If in doubt, just make sure the blue part of the cable is facing the USB ports on the Raspberry Pi:
Now boot your Raspberry Pi (plug the power in and turn it on).
Once booted, update your Raspberry Pi by running the following commands in a terminal window:
sudo apt-get-updatesudo apt full-upgrade
Please note that from the latest 'Bullseye' release of Raspberry Pi OS, you no longer need to enable your camera within the Raspberry Pi configuration.
How to take a photos and videos with your Raspberry Pi Camera Module
With the latest 'Bullseye' release of Raspberry Pi OS we now use libcamera to take photos and videos. (If you're using an older version such as 'Buster', you'll need to use the older raspistill/raspivid).
libcamera-jpeg is a command line application that allows you to capture images and videos with your camera module. Below is an example of this command in use.
To capture a simple image in jpeg format, type the following command into your terminal window:
libcamera-jpeg -o image.jpg
Here, 'image' is the name of your image that will be saved to your Raspberry Pi.
This is one of the simplest ways to take a picture and save the image. libcamera has many powerful options you can use - please read the official documentation to learn more.
libcamera-vid is a command line application that allows you to capture video with your camera module. Below is an example of this command in use.
To capture a 10 second video with your Raspberry Pi camera module, run the following command:
libcamera-vid -t 10000 -o video.h264
Here, 'video' is the name of your video and "10000" is the number of milliseconds we're telling it to record for (10 seconds). libcamera-vid has many powerful options you can use including raw image formats - please read the official documentation to learn more.