libcamera Overview

Modern camera stack for Linux devices and embedded systems

Introduction to libcamera

libcamera is an open-source Linux camera stack developed to provide support for complex camera systems found in embedded and mobile devices. It replaces proprietary vendor solutions by offering a standardized framework and API for camera handling, image capture, and stream management.

Goals & Purpose

libcamera aims to:

  1. Enable device-independent camera control.
  2. Expose a uniform API for camera applications.
  3. Handle the ISP pipeline, sensor tuning, and format negotiation.
  4. Support multi-camera and stereo configurations.

Architecture

libcamera consists of the following components:

ComponentDescription
CameraManagerHandles camera detection and global camera access control.
CameraRepresents a single physical or logical camera device.
PipelineHandlerEncapsulates hardware-specific logic, tuning, and streaming.
FrameBufferStores captured frame data.
Controls APIHandles setting and querying camera controls like exposure, gain, etc.

Installation (Debian/RPi)


sudo apt update
sudo apt install libcamera-apps libcamera-dev libcamera0

Basic CLI Tools

libcamera comes with built-in command-line tools:

  1. libcamera-hello — simple preview test.
  2. libcamera-jpeg — capture and save JPEGs.
  3. libcamera-still — for high-resolution stills.
  4. libcamera-vid — record video to file.
  5. libcamera-raw — raw frame output.

libcamera-still -o image.jpg
libcamera-vid -t 10000 -o video.h264

Using libcamera in C++


#include <libcamera/libcamera.h>

int main() {
	libcamera::CameraManager cm;
	cm.start();
	auto cameras = cm.cameras();
	for (auto &cam : cameras) {
		std::cout << "Found camera: " << cam->id() << std::endl;
	}
	cm.stop();
	return 0;
}

Note: Link against -lcamera when compiling.

Supported Platforms

DeviceStatusNotes
Raspberry Pi 4/5✔ FullUses BCM ISP pipeline handler
RK3399 / Rockchip✔ PartialRequires community patches
Generic V4L2 devices✔ BasicNo ISP or control tuning

libcamera vs V4L2

FeaturelibcameraV4L2
Hardware Abstraction
Multi-Cam Support
User APIModern C++C, ioctl-heavy
Sensor Tuning

Development Tips


# Build from source
git clone https://git.libcamera.org/libcamera/libcamera.git
cd libcamera
meson build
ninja -C build
sudo ninja -C build install

Requires: meson, ninja, libudev-dev, python3-yaml