Crate rscam

Source
Expand description

Fast wrapper for v4l2.

use rscam::{Camera, Config};

let mut camera = Camera::new("/dev/video0").unwrap();

camera.start(&Config {
    interval: (1, 30),      // 30 fps.
    resolution: (1280, 720),
    format: b"MJPG",
    ..Default::default()
}).unwrap();

for i in 0..10 {
    let frame = camera.capture().unwrap();
    let mut file = fs::File::create(&format!("frame-{}.jpg", i)).unwrap();
    file.write_all(&frame[..]).unwrap();
}

The wrapper uses v4l2 (e.g. v4l2_ioctl() instead of ioctl()) until feature no_wrapper is enabled. The feature can be useful when it’s desirable to avoid dependence on libv4l2.

Modules§

Structs§

Enums§

Constants§

Traits§

Functions§

  • Alias for Camera::new().

Type Aliases§