Modern camera stack for Linux devices and embedded systems
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.
libcamera aims to:
libcamera consists of the following components:
Component | Description |
---|---|
CameraManager | Handles camera detection and global camera access control. |
Camera | Represents a single physical or logical camera device. |
PipelineHandler | Encapsulates hardware-specific logic, tuning, and streaming. |
FrameBuffer | Stores captured frame data. |
Controls API | Handles setting and querying camera controls like exposure, gain, etc. |
sudo apt update
sudo apt install libcamera-apps libcamera-dev libcamera0
libcamera
comes with built-in command-line tools:
libcamera-hello
— simple preview test.libcamera-jpeg
— capture and save JPEGs.libcamera-still
— for high-resolution stills.libcamera-vid
— record video to file.libcamera-raw
— raw frame output.
libcamera-still -o image.jpg
libcamera-vid -t 10000 -o video.h264
#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.
Device | Status | Notes |
---|---|---|
Raspberry Pi 4/5 | ✔ Full | Uses BCM ISP pipeline handler |
RK3399 / Rockchip | ✔ Partial | Requires community patches |
Generic V4L2 devices | ✔ Basic | No ISP or control tuning |
Feature | libcamera | V4L2 |
---|---|---|
Hardware Abstraction | ✔ | ✘ |
Multi-Cam Support | ✔ | ✘ |
User API | Modern C++ | C, ioctl-heavy |
Sensor Tuning | ✔ | ✘ |
# 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