6 releases

0.2.4 Sep 25, 2022
0.2.3 Sep 25, 2022
0.1.0 Sep 1, 2020

#401 in Hardware support

Download history 2/week @ 2024-01-29 5/week @ 2024-02-05 44/week @ 2024-02-19 21/week @ 2024-02-26 9/week @ 2024-03-04 8/week @ 2024-03-11 5/week @ 2024-03-18 145/week @ 2024-04-01

160 downloads per month
Used in 2 crates (via eye-hal)

MIT license

4.5MB
82K SLoC

C 37K SLoC // 0.2% comments Assembly 22K SLoC // 0.2% comments GNU Style Assembly 9K SLoC // 0.1% comments Bitbake 5K SLoC C++ 4.5K SLoC // 0.1% comments Java 3K SLoC // 0.4% comments JavaScript 1K SLoC // 0.0% comments Objective-C++ 1K SLoC // 0.2% comments Rust 297 SLoC // 0.0% comments Prolog 25 SLoC Batch 22 SLoC Shell 5 SLoC

Safe openpnp-capture bindings

license

This crate provides safe bindings to the openpnp-capture library for cross-platform camera capture.

Layout

The sys subdir contains the openpnp_capture_sys crate which holds the actual FFI bindings wrapping the C API.

Usage

openpnp_capture = "0.1"

Example

use openpnp_capture::{Device, Format, Stream};

fn main() {
    // Fetch some generic device information
    let devices = Device::enumerate();
    println!("Found {} devices.", devices.len());

    // Choose the first device we see
    let dev = Device::new(devices[0]).expect("Failed to open device");

    // Create the stream
    let format = Format::default().width(1280).height(720).fps(30);
    let mut stream = Stream::new(&dev, &format).expect("Failed to create stream");

    // Print some format information
    println!(
        "[0] {} ({}x{}@{})",
        stream.format().fourcc,
        stream.format().width,
        stream.format().height,
        stream.format().fps
    );

    // Prepare a buffer to hold camera frames
    let mut rgb_buffer = Vec::new();

    // Capture some frames
    stream.advance();
    stream.read(&mut rgb_buffer);
}

Have a look at the provided examples for more sample applications.

Dependencies