Use MIPI camera

Raspberry Pi 5 combines the previous CSI and DSI interfaces into two dual-purpose CSI/DSI (MIPI) ports.

Configure the camera

To use the Raspberry Pi camera or a third-party camera, you can modify the camera configuration according to the table below:

Camera moduleFile located at: /boot/firmware/config.txt
V1 camera (OV5647)dtoverlay=ov5647
V2 camera (IMX219)dtoverlay=imx219
HQ camera (IMX477)dtoverlay=imx477
GS camera (IMX296)dtoverlay=imx296
Camera module 3 (IMX708)dtoverlay=imx708
IMX290 and IMX327dtoverlay=imx290,clock-frequency=74250000
or (both modules share IMX290 kernel driver; for the correct frequency,
refer to the module vendor's instructions)
dtoverlay=imx290,clock-frequency=37125000
IMX378 typedtoverlay=imx378
OV9281 seriesdtoverlay=ov9281

If you are not using the official Raspberry Pi camera, you can modify the config.txt file according to the content above the table and add the dtoverlay content to the /boot/firmware/config.txt file.

image-20240102190604786

For example: Raspberry Pi uses IMX219 camera, connect the camera to the J4 interface of Raspberry Pi, and then modify the /boot/firmware/config.txt file:

image-20240102190547875

Modify the configuration file and restart to take effect!

Use the camera

Preview the camera

Type this command in the terminal to display the preview window for about 5 seconds

Running this command in the terminal will keep the preview window displayed. You can exit it by using the window close button and Ctrl+C keys!

Take a photo

Display a 5-second preview, then capture the image and save it as a test.jpg file

Display a 2-second preview, then capture the image and save it as a test.jpg file. The image is 640 pixels wide and 480 pixels high.

rpicam-still

This command can be used to save files in different formats:

Capture images continuously at 2 second intervals for a total capture time of 30 seconds and save each image with a file name format like image0001.jpg:

Video recording

rpicam-vid

Command for video recording using the camera module on the Raspberry Pi.

Example: Record 10 seconds of video and write it to the test.h264 file

Play video

Note: If the test.h264 file cannot be played and an error occurs, please try the following method to solve it.

Error solution

Modify the frame rate of H264 playback per second

image-20231212203607442

image-20231212203645482

image-20231215142018906