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:

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

Getting Started


For Native cameras, please refer to the following page according to the camera you are using:

Native Camera Board list:

Resolution Sensor
5MP OV5647
8MP IMX219
12MP IMX477
12MP 477M
12MP IMX708
12MP IMX378
16MP IMX519
64MP 64MP Hawkeye
64MP 64MP OV64A40
0.3MP OV7251
1.58MP IMX296
1MP OV9281
2MP OV2311
2MP IMX290/IMX462/IMX327

Howdy

libcamera apps are renamed to rpicam apps in Raspberry Pi bookworm os. The usages are the same between both apps.

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, please use the --help parameter to browse:

rpicam-hello --help
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, please use the --help parameter to see

rpicam-jpeg --help
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

Continuous Auto-Capture


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

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

For more parameters, please use the --help parameter to see

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

Autofocus/Manual Focus Function


Tip

For cameras with focus motors, we have added autofocus parameters to enable single autofocus and continuous autofocus functions.
Different cameras use their corresponding operation commands, please enter the camera content you need according to the index:

For Arducam 16MP/64MP Autofocus camera

Continuous Autofocus

rpicam-still -t 0 

rpicam-still -t 0 --autofocus-mode continuous

Single Autofocus

rpicam-still -t 0 --autofocus-mode auto

Manual Focus

Install libcamera-tools
Keyboard Control

Note

  • Focus Control Keys
    Under libcamera log window:
  • f + Enter: Triggers single-shot autofocus operation
  • a + Enter: Increments lens position (step size: 1 unit)
  • d + Enter: Decrements lens position (step size: 1 unit)
  • Usage Steps
  • Execute the command to enter preview mode
  • Use keyboard controls in the libcamera log window
  • Type 'a' or 'd' followed by Enter to adjust focus position
  • Type 'f' followed by Enter for quick autofocus when needed
rpicam-still -t 0 --autofocus-mode manual -k 
Adjust Lens Position
rpicam-still -t 0 --autofocus-mode manual --lens-position 5

Autofocus Before Capture Images

rpicam-still -t 0 --autofocus-on-capture

Set Focus Range

# Normal
rpicam-still -t 0 --autofocus-range normal

# Close Focus
rpicam-still -t 0 --autofocus-range macro
  • For OV5647/IMX219 and IMX477 Camera Module

Note

The IMX219, OV5647, IMX477 cameras will need to use a specific tuning data file to achieve autofocus function.

Please refer to the following corresponding docs to get more details and operation steps for above camera modules:

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 cameras with focus motors, we have added autofocus parameters to enable single autofocus and continuous autofocus functions

Single autofocus

rpicam-vid -t 0 --autofocus-mode auto

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

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

For more parameters, please use the --help parameter to see

rpicam-vid --help
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, please use the --help parameter to see

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