We will not respond to PRs or issues that have not been discussed on Discord. Also, Discord is only available in Japanese.
Please read https://github.com/shiguredo/oss before use.
利用前に https://github.com/shiguredo/oss をお読みください。
Important
libcamera v0.7.0+rpt20260205
libcamera は動的リンクで利用しています。上記バージョンと互換性のない libcamera がインストールされている環境では正常に動作しない可能性があります。
Rust で実装された libcamera のバインディングです。
- libcamera 本体は
pkg-config経由で動的リンク - 自前 C ラッパーは静的コンパイルしてクレートに埋め込み
- 安全な Rust API による所有権・ライフタイム管理
- コールバックによるフレームキャプチャ
- コントロール (露出、ホワイトバランス、フォーカス等) の取得・設定 (対応コントロール一覧)
libcamera-rs/
├── c-api/ # C/C++ ラッパー (libcamera C++ API → C API)
├── src/ # 高レベル safe Rust API + FFI (bindgen 生成)
└── examples/ # サンプル
- Raspberry Pi OS で libcamera が動作する環境
libcamera-devパッケージが必要
sudo apt install libcamera-devDev Containers を使えば macOS arm64 でもクロスコンパイルによるビルドが可能です。
use shiguredo_libcamera::{CameraManager, StreamRole};
let manager = CameraManager::new().unwrap();
let count = manager.cameras_count();
for i in 0..count {
let camera = manager.get_camera(i).unwrap();
println!("Camera {i}: {}", camera.id());
}use shiguredo_libcamera::{
CameraManager, FrameBufferAllocator, StreamRole,
};
let manager = CameraManager::new().unwrap();
let mut camera = manager.get_camera(0).unwrap();
camera.acquire().unwrap();
let mut config = camera.generate_configuration(&[StreamRole::VideoRecording]).unwrap();
config.validate().unwrap();
camera.configure(&mut config).unwrap();
let stream = config.at(0).unwrap().stream().unwrap();
let allocator = FrameBufferAllocator::new(&camera);
let buffer_count = allocator.allocate(&stream).unwrap();
camera.on_request_completed(move |completed| {
if let Some(buffer) = completed.find_buffer(&stream) {
let meta = buffer.metadata();
println!("Frame {}: timestamp={}", meta.sequence, meta.timestamp);
}
});
camera.start().unwrap();
// ...
camera.stop().unwrap();use shiguredo_libcamera::core;
let mut controls = request.controls();
controls.set_f32(&core::BRIGHTNESS, 0.2);
controls.set_f32(&core::CONTRAST, 1.5);
controls.set_f32(&core::SATURATION, 1.2);サンプルの JSON 出力には nojson を利用しています。
カメラ一覧とストリーム情報を表示します。
cargo run --example list_camerasフレームキャプチャを行い、メタデータを表示します。
cargo run --example captureコントロールを設定してキャプチャし、メタデータを読み取ります。
cargo run --example controlsApache License 2.0
Copyright 2026-2026, Shiguredo Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.