Cameras for Raspberry Pi

  1. Home
  2. Docs
  3. Cameras for Raspberry Pi
  4. IMX519 Autofocus Camera and Raspberry Pi libcamera Guide

IMX519 Autofocus Camera and Raspberry Pi libcamera Guide

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 their 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
ArducamV2 Series / HQ Series / Pivariety Series / High-Resolution Autofocus Camera


Please avoid using our 16MP autofocus camera module with the official PoE HAT or touchscreen.

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?

For 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
chmod +x

Step 2. Install libcamra-dev

./ -p libcamera_dev

Step 3. Install libcamera-apps

./ -p libcamera_apps

Step 4. Install the kernel driver

./ -p imx519_kernel_driver

Step 5. Install the focus adjustment software

git clone

Step 6. Reboot your Pi

For Raspbian Bullseye users running on Pi Zero ~ Pi 3, please execute the follows:

1. Open a terminal
2. Run sudo raspi-config
3. Navigate to Advanced Options
4. Enable Glamor graphic acceleration
5. Reboot your Pi

Meanwhile, you also need to execute the following steps:
1. Open a terminal
2. Run sudo raspi-config
3. Navigate to Advanced Options
4. Navigate to GL Driver
5. Select GL (Full KMS)
6. Reboot your Pi

For more details, please refer to the official forum guide on how to configure the camera module >>

For Raspberry Pi Compute Module 3/4

You need to install the latest Raspberry Pi system (after 2022/01/28), and do not execute rpi-update
After installing the system and drivers (follow the above instructions), add the following information to /boot/config.txt:

Then reboot.

List all cameras:
libcamera-still –list-cameras

Specify camera:
libcamera-still -t 0 –camera 0
libcamera-still -t 0 –camera 1

Camera Modules in the Quad-Camera Kit

The camera modules are exclusively built for the quad-camera adapter HAT for accurate synchronization, they can only be used with the HAT connected to a Pi, connecting them directly to a Raspberry Pi will not work.

For one-time autofocus, append –autofocus to your command line:

libcamera-still -t 5000 -o test.jpg --autofocus

If you want to manually adjust the focus, please follow these steps:

Step 1. Open a preview window

libcamera-still -t 0

Step 2. Use our focus adjustment tool

cd Arducam-Pivariety-V4L2-Driver/focus
python3 -d /dev/v4l-subdev1

Step 3. Press the Up/Down Arrow for focus adjustment, press “ctrl + c” to save, or “r” to


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’re available for both commands:

-h [ --help ]

Print out the help message.


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.


Sets the information string on the titlebar. Available values:

%frame (frame number)

%fps (framerate)

%exp (shutter speed)

%ag (analogue gain)

%dg (digital gain)

%rg (red colour gain)

%bg (blue colour gain)

%focus (focus FoM value)

%aelock (AE locked status)


Set the output image width.


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.


Set the file name for configuring the post-processing.


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,height. E.G. 0,0,640,480

-f [ --fullscreen ]

Use a fullscreen preview window.


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


Request a horizontal flip transform.


Request a vertical flip transform.


Request an image rotation, 0 or 180


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


Set a fixed shutter speed.


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


Set a fixed gain value.


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


Set the exposure mode (normal, sport).


Set the EV exposure compensation, where 0 = no change


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


Flush output data as soon as possible.

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

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

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

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

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

Set the fixed framerate for preview and video modes.

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

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

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

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

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

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

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 signal received.

Pause or resume video recording when signal 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.


Time interval (in ms) between timelapse captures.


Initial frame counter value for timelapse captures.


Use date format for output file names.


Use system timestamps for output file names.


Set JPEG restart interval.


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 file in DNG format.


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


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).


Set the encoding profile (h264 only).


Set the encoding level (h264 only).

-g [ --intra ]

Set the intra frame period (h264 only).


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


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


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).


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


Break the recording into files of approximately this many milliseconds.


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


Was this article helpful to you? Yes 8 No 4