Cameras for Raspberry Pi

  1. Home
  2. Docs
  3. Cameras for Raspberry Pi
  4. What is libcamera?

What is libcamera?

what is libcamera and how you cana use it on Raspberry Pi

libcamera is an open-source camera stack, which was used by Raspberry Pi to develop its latest camera software library. It offers users more lower-level access than the old raspistill and is fully open-sourced.

The libcamera-apps that are currently available for Raspberry Pi:

  1. libcamera-hello will give you a preview of the camera module.
  2. libcamera-jpeg will capture still images after showing you a preview window.
  3. libcamea-still offers all the features of raspistill.
  4. libcamera-vid offers all the features of raspivid.
  5. libcamera-raw will get raw frames from the image sensor.
  6. libcamera-detect will work with tensorflow lite to automatically capture JPEG images when certain objects appear in the frame, it needs to be built first.

For more information, please refer to:

The libcamera-Compatible Camera Lists

Below is a complete list of camera modules that work perfectly well with libcamera-apps.

Camera VendorsCamera Models
Raspberry Pi
V1/V2/HQ
ArducamV2 Series / HQ Series / Pivariety Series / 16MP Series / 64MP Series

Using Arducam Cameras with Picamera2 >

Supported Resolutions & Frame Rates

Camera Module v1Camera Module v2HQ Camera16MP-AF64MP-AF
Video modes (preview)1080p30, 720p60 and 640 × 480p60/901080p30, 720p60 and 640 × 480p60/901080p30, 720p60 and 640 × 480p60/904656×[email protected], 3840×[email protected], 2328×[email protected], 1920×[email protected], 1280×[email protected]9152×[email protected], 4624×[email protected], 3840×[email protected], 2312×[email protected], 1920×[email protected], 1280×[email protected]

Note

Please make sure your Raspberry Pi OS is downloaded from these two official sources:

Raspberry Pi Buster > (Note: The new version of Buster kernel is no longer supported)

Raspberry Pi Bullseye >

How to install libcamera?

The official Raspberry Pi camera modules (V1/V2/HQ), it’s already built in.

If you are using the Arducam Autofocus Camera for the first time, please follow these steps:

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 libcamra-dev

./install_pivariety_pkgs.sh -p libcamera_dev

Step 3. Install libcamera-apps

./install_pivariety_pkgs.sh -p libcamera_apps

Advanced usages of libcamera & libcamera-apps

For full details on how to use the libcamera for project-bulding, please refer to this article.

Below are the options that are available for both commands:

-h [ --help ]

Print out the help message.

--version

Displays the build version number.

-v [ --verbose ]

Output extra debug and diagnostics.

-c [ --config ]

Read the options from a file. If no filename is specified, default to config.txt. In case of duplicate options, the ones provided on the command line will be used. Note that the config file must only contain the long form options.

--info-text

Sets the information string on the title bar. Available values:

%frame (frame number)

%fps (framerate)

%exp (shutter speed)

%ag (analog gain)

%dg (digital gain)

%rg (red color gain)

%bg (blue color gain)

%focus (focus FoM value)

%aelock (AE locked status)

--width

Set the output image width.

--height

Set the output image height.

-t [ --timeout ]

Time (in ms) for which program runs. The default value is 5000.

-o [ --output ]

Set the output file name.

--post-process-file

Set the file name for configuring the post-processing.

--rawfull

Force use of full-resolution raw frames.

-n [ --nopreview ]

Do not show a preview window.

-p [ --preview ]

Set the preview window dimensions, given as x,y, width, and height. E.G. 0,0,640,480

-f [ --fullscreen ]

Use a fullscreen preview window.

--qt-preview

Use Qt-based preview window (WARNING: causes heavy CPU load, fullscreen not supported)

--hflip

Request a horizontal flip transform.

--vflip

Request a vertical flip transform.

--rotation

Request an image rotation, 0 or 180

--roi

Set region of interest (digital zoom) e.g. 0.25,0.25,0.5,0.5

--shutter

Set a fixed shutter speed.

--analoggain

Set a fixed gain value (synonym for ‘gain’ option).

--gain

Set a fixed gain value.

--metering

Set the metering mode (center, spot, average, custom).

--exposure

Set the exposure mode (normal, sport).

--ev

Set the EV exposure compensation, where 0 = no change

--awb

Set the AWB mode (auto, incandescent, tungsten, fluorescent, indoor, daylight, cloudy, custom).

--awbgains

Flush output data as soon as possible.

--wrap
When writing multiple output files, reset the counter when it reaches this number.

--brightness
Adjust the brightness of the output images, in the range -1.0 to 1.0

--contrast
Adjust the contrast of the output image, where 1.0 = normal contrast.

--saturation
Adjust the colour saturation of the output, where 1.0 = normal and 0.0 = greyscale.

--sharpness
Adjust the sharpness of the output image, where 1.0 = normal sharpening.

--framerate
Set the fixed framerate for preview and video modes.

--denoise
Sets the Denoise operating mode: auto, off, cdn_off, cdn_fast, cdn_hq

--viewfinder-width
Width of viewfinder frames from the camera (distinct from the preview window size.

--viewfinder-height
Height of viewfinder frames from the camera (distinct from the preview window size).

--tuning-file
Name of camera tuning file to use, omit this option for libcamera default behaviour.

--lores-width
Width of low resolution frames (use 0 to omit low resolution stream.

--lores-height
Height of low resolution frames (use 0 to omit low resolution stream.

--autofocus
Flush output data as soon as possible.

-k [ --keypress ]
Perform capture when ENTER pressed.

Pause or resume video recording when ENTER pressed.

-s [ --signal ]

Perform capture when the signal received.

Pause or resume video recording when the signal is received.

Options only available for libcamera-still

-q [ --quality ]

Set the JPEG quality parameter.

-x [ --exif ]

Add these extra EXIF tags to the output file.

--timelapse

Time interval (in ms) between timelapse captures.

--framestart

Initial frame counter value for timelapse captures.

--datetime

Use date format for output file names.

--timestamp

Use system timestamps for output file names.

--restart

Set JPEG restart interval.

--thumb

Set thumbnail parameters as width:height: quality

-e [ --encoding ]

Set the desired output encoding, either jpg, png, rgb, bmp or yuv420

-r [ --raw ]

Also, save raw files in DNG format.

--latest

Create a symbolic link with this name to the most recent saved file

--immediate

Perform first capture immediately, with no preview phase.

Options only available for libcamera-vid

-b [ --bitrate ]

Set the bitrate for encoding, in bits/second (h264 only).

--profile

Set the encoding profile (h264 only).

--level

Set the encoding level (h264 only).

-g [ --intra ]

Set the intra frame period (h264 only).

--inline

Force PPS/SPS header with every I frame (h264 only).

--codec

Set the codec to use, either h264, mjpeg or yuv420.

--save-pts

Save a timestamp file with this name.

-q [ --quality ]

Set the MJPEG quality parameter (mjpeg only).

-l [ --listen ]

Listen for an incoming client network connection before sending data to the client.

-i [ --initial ]

Use ‘pause’ to pause the recording at startup, otherwise ‘record’ (the default).

--split

Create a new output file every time recording is paused and then resumed.

--segment

Break the recording into files of approximately this many milliseconds.

--circular

Write output to a circular buffer which is saved on exit.

Was this article helpful to you? Yes No 1