eye 0.1.0

Cross platform camera capture and control
docs.rs failed to build eye-0.1.0
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.
Visit the last successful build: eye-0.5.0

Eye

license Build Status

Eye is a cross platform camera capture and control library written in native Rust. It features multiple platform backends, such as v4l2 for Linux. Buffers are captured by accessing 'streams'. The stream concept is used to facilitate additional features such as colorspace conversion.

Eye is a very young library and its API is subject to change (as denoted by the 0.x.x version number). We follow the semver approach, meaning each new feature will bump the minor version by one.

Goals

  • Zero-copy (in userspace) image capture
  • Device discovery and identification
  • Device management, e.g. frame parameters or focus control
  • Easy image conversion into common formats such as RGB

Usage

Below you can find a quick example usage of this crate. It introduces the basics necessary for image capturing.

use eye::prelude::*;

fn main() {
    // First, we need a capture device to read images from. For this example, let's just choose
    // whatever device the system assigned the index zero. For Linux, this will be the first device
    // that the machine saw.
    let mut dev = DeviceFactory::create(0).expect("Failed to open video device");

    // Now fetch the current device format. The format contains parameters such as frame width,
    // height and the buffer format (RGB, JPEG, etc).
    let format = dev.get_format().expect("Failed to read native format");

    // Since we want to capture images, we need to access the native image stream of the device.
    // The backend will internally select a suitable implementation for the platform stream. On
    // Linux for example, most devices support memory-mapped buffers.
    //
    // Keep in mind that no format conversion is performed by default, so the frames you get in
    // this stream are directly handed to you without any copy. If you need a common frame format
    // such as raw RGB, you will have to create a seperate stream to perform the conversion.
    let mut stream = dev.stream().expect("Failed to setup capture stream");

    // Here we create a loop and just capture images as long as the device produces them. Normally,
    // this loop will run forever unless we unplug the camera or exit the program.
    loop {
        let frame = stream.next().expect("Failed to capture frame");
    }
}

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