docs.rs failed to build shiguredo_libcamera-2026.1.0-canary.1
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
libcamera-rs
About Shiguredo's open source software
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 をお読みください。
対応 libcamera バージョン
[!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パッケージが必要
Dev Containers
Dev Containers を使えば macOS arm64 でもクロスコンパイルによるビルドが可能です。
使い方
カメラの列挙
use ;
let manager = new.unwrap;
let count = manager.cameras_count;
for i in 0..count
フレームキャプチャ
use ;
let manager = new.unwrap;
let mut camera = manager.get_camera.unwrap;
camera.acquire.unwrap;
let mut config = camera.generate_configuration.unwrap;
config.validate.unwrap;
camera.configure.unwrap;
let stream = config.at.unwrap.stream.unwrap;
let allocator = new;
let buffer_count = allocator.allocate.unwrap;
camera.on_request_completed;
camera.start.unwrap;
// ...
camera.stop.unwrap;
コントロールの設定
use core;
let mut controls = request.controls;
controls.set_f32;
controls.set_f32;
controls.set_f32;
サンプル
サンプルの JSON 出力には nojson を利用しています。
list_cameras
カメラ一覧とストリーム情報を表示します。
capture
フレームキャプチャを行い、メタデータを表示します。
controls
コントロールを設定してキャプチャし、メタデータを読み取ります。
ライセンス
Apache 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.