#low-latency #image #cam #autocxx

sys raspicam-rs

Pragmatic Rust bindings to the raspicam C++ library

4 releases

0.1.3 Oct 12, 2022
0.1.2 Oct 11, 2022
0.1.1 Oct 11, 2022
0.1.0 Oct 11, 2022

MIT license

26K SLoC

C 22K SLoC // 0.2% comments C++ 3.5K SLoC // 0.2% comments Rust 567 SLoC // 0.0% comments Shell 32 SLoC // 0.1% comments


docs.rs Crates.io

Rust bindings to the amazing C++ raspicam library (with optional OpenCV utilities)!

This is a followup to a Rust-based robotics project I worked where high FPS low latency and full color support was a requirement: ez-aquarii


You MUST be on a 32-bit install. The raspberry pi camera libraries do NOT work on a 64-bit installation. See: https://github.com/raspberrypi/userland/issues/688

A prerequisite is you have to compile the raspicam library and install it. This repo has a install script for convenience that'll do everything for you:

curl https://raw.githubusercontent.com/bluskript/raspicam-rs/master/install.sh | sudo bash

Install dependencies:

sudo apt install clang libclang-dev

If you are using opencv integration, also install libopencv-dev and enable the opencv feature in the crate:

raspicam-rs = { version = "0.1.2", features = ["opencv"] }
opencv = "0.70.0"

Example usage showing how to capture a single image and save it:

use image::RgbImage;
use raspicam_rs::{

fn main() {
    let mut raspicam = raspicam_rs::RaspiCam::new();
        .set_capture_size(480, 480)
    let img = RgbImage::from_raw(480, 480, raspicam.grab().unwrap().to_vec()).unwrap();

How to configure

These bindings use something similar to a builder pattern to configure the camera. You can chain configuration commands together:

let mut raspicam = raspicam_rs::RaspiCam::new();

If there is a method that isn't available directly, you can call methods on the internal C++ object like so:

let mut camera = raspicam_rs::RaspiCam::new();

Achieving high FPS low latency fullcolor

In my experience, high FPS fullcolor realtime processing can be achieved using low resolutions (480x480 as an example), sensor mode 7, shutter speed 15000, and setting the framerate 90.

A real-world demo of low latency camera capturing (predates this library but same result can be achieved): Check Here


~127K SLoC