Skip to content

libcamera and rpicam-apps

Introduction


libcamera is a new software library aimed at supporting complex camera systems directly from the Linux operating system. In the case of the Raspberry Pi it enables us to drive the camera system directly from open source code running on ARM processors.

libcamera presents a C++ API to applications and works at the level of configuring the camera and then allowing an application to request image frames. These image buffers reside in system memory and can be passed directly to still image encoders (such as JPEG) or to video encoders (such as h.264), though such ancillary functions as encoding images or displaying them are strictly beyond the purview of libcamera itself.

At Arducam, we added more RPI camera support and improved the existing libcamera with extensive features like auto-focus, external trigger, strobe functions, auto-load camera calibration parameters with our Pivariety solution and modified version of libcamera.

Tip

Raspberry Pi OS Bookworm renamed the camera capture applications from libcamera- to rpicam-. Symbolic links allow users to use the old names for now. Adopt the new application names as soon as possible. Raspberry Pi OS versions prior to Bookworm still use the libcamera-* name.

Picamera2 is not supported on:

  • Images based on Buster or earlier releases.
  • Raspberry Pi OS Legacy images.
  • Bullseye (or later) images where the legacy camera stack has been re-enabled.

More about libcamera

You can get more information about libcamera for Raspberry Pi at the following link:

Note

[<span style="color:red;">Raspberry Pi Camera Software Guide - libcamera/rpicam</span>](https://www.raspberrypi.com/documentation/computers/camera_software.html)

libcamera is an open source Linux community project. More information is available at the

Getting Started


Note

After running sudo apt update && sudo apt upgrade, if you want to continue using Arducam Pivariety cameras, you will need to reinstall the Arducam libcamera packages. This is because the system update will overwrite the custom Arducam libcamera modifications with the standard Raspberry Pi libcamera packages.To reinstall the Arducam libcamera packages, simply run the installation script again following the steps below:

Step 1. Download the bash scripts

wget -O install_pivariety_pkgs.sh https://github.com/ArduCAM/Arducam-Pivariety-V4L2-Driver/releases/download/install_script/install_pivariety_pkgs.sh 
chmod +x install_pivariety_pkgs.sh

Step 2. Install libcamera

./install_pivariety_pkgs.sh -p libcamera_dev

Step 3. Install libcamera-apps

./install_pivariety_pkgs.sh -p libcamera_apps

Troubleshooting

If you receive the following error when installing libcamera, you can use the command ./install_pivariety_pkgs.sh -l to update your package:

libcamera-error-1

You can use following command to update your package:

./install_pivariety_pkgs.sh -l

rpicam-hello


rpicam-hello is the equivalent of a "hello world" application for the camera. It starts the camera, displays a preview window, and does nothing else (Note: Raspberry Pi OS versions prior to Bookworm still support using the libcamera-hello command). For example:

rpicam-hello
For more parameters and options on Raspberry Pi, you can also refer to
Raspberry Pi Official Doc - Camera Software: rpicam-hello

rpicam-jpeg


rpicam-jpeg is a simple still image capture application. It deliberately avoids some of the additional features of rpicam-still which attempts to emulate raspistill more fully. As such the code is significantly easier to understand, and in practice still provides many of the same features (Note: Raspberry Pi OS versions prior to Bookworm still support using the libcamera-jpeg command).

To capture a full resolution JPEG image use

rpicam-jpeg -o test.jpg
For more parameters and options on Raspberry Pi, you can also refer to
Raspberry Pi Official Doc - Camera Software: rpicam-jpeg

rpicam-still


rpicam-still is very similar to rpicam-jpeg but supports more of the legacy raspistill options (Note: Raspberry Pi OS versions prior to Bookworm still support using the libcamera-still command). As before, a single image can be captured with:

rpicam-still -o test.jpg
For more parameters and options on Raspberry Pi, you can also refer to
Raspberry Pi Official Doc - Camera Software: rpicam-still

rpicam-vid


rpicam-vid is the video capture application. By default it uses the Raspberry Pi’s hardware H.264 encoder. It will display a preview window and write the encoded bitstream to the specified output (Note: Raspberry Pi OS versions prior to Bookworm still support using the libcamera-vid command). For example, to write a 10 second video to file use

rpicam-vid -t 10000 -o test.h264
For more parameters and options on Raspberry Pi, you can also refer to
Raspberry Pi Official Doc - Camera Software: rpicam-vid

rpicam-raw


rpicam-raw is like a video recording application except that it records raw Bayer frames directly from the sensor. It does not show a preview window (Note: Raspberry Pi OS versions prior to Bookworm still support using the libcamera-raw command). For a 2 second raw clip use.

rpicam-raw -t 2000 -o test.raw
For more parameters and options on Raspberry Pi, you can also refer to
Raspberry Pi Official Doc - Camera Software: rpicam-raw

Common Command Line Options


The following options apply across all the rpicam-apps with similar or identical semantics, unless noted otherwise.

--autofocus [=arg(=1)] (=0)           Trigger Autofocus once.

For cameras with focus motors, we have added autofocus parameters to enable single autofocus and continuous autofocus functions.

Example: Continuous automatic photo taking, 1 shot per second within 5 seconds

rpicam-still -t 5000 --datetime -n --timelapse 1000

--help,     -h      Print help information for the application

The --help option causes every application to print its full set of command line options with a brief synopsis of each, and then quit.

--version           Print out a software version number

All rpicam-apps will, when they see the --version option, print out a version string both for rpicam and rpicam-apps and then quit, for example:

--list-cameras          List the cameras available for use

The --list-cameras will display the available cameras attached to the board that can be used by the application. This option also lists the sensor modes supported by each camera.