lumiavis 0.2.0

Lightweight Rust library for camera capture, image processing, preview, and simple video pipelines
Documentation

Lumiavis provides a minimal and clean abstraction over V4L2 (Linux) and Media Foundation (Windows) to capture high-quality webcam frames. Beyond simple capture, it includes a robust image processing pipeline to load, manipulate, and export images and video sequences effortlessly.

✨ Features

  • 🎥 Cross-Platform Capture: Automatically negotiates the best resolution and framerate without messy boilerplate.
  • 🖼️ Image Processing: Easily load images from disk, resize, crop, and apply grayscale filters.
  • 🖌️ Annotations: Draw geometric shapes, text, bounding boxes, and real-time FPS overlays.
  • 🎞️ Video Export: Capture a sequence of JPEGs and compile them into an MP4 video using our FFmpeg bridge.

🚀 Quick Start

1. Camera Capture

Lumiavis makes it incredibly simple to find your camera, negotiate the maximum quality, and capture a photo:

use lumiavis::{Camera, CameraConfig};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Automatically configures the camera for its highest resolution and FPS
    let config = CameraConfig::best_quality(0);
    
    // Open the camera and read a frame
    let mut camera = Camera::open(config)?;
    let frame = camera.read_frame()?;
    
    // Decode and save to disk
    frame.to_image()?.save("webcam_photo.jpg")?;
    
    Ok(())
}

2. Image Processing

No webcam? No problem. Lumiavis can also serve as a standalone image manipulation tool:

use lumiavis::{Image, Resolution, RgbColor};
use lumiavis::core::image::ops::crop::CropRect;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Load an image directly from disk
    let mut image = Image::load("input.jpg")?;

    // Perform a series of operations cleanly
    let processed = image
        .resize(Resolution::new(800, 600))?
        .crop(CropRect { x: 200, y: 150, width: 400, height: 300 })?
        .grayscale()?;

    processed.save("output_processed.jpg")?;
    
    Ok(())
}

📚 Documentation

Dive deeper into Lumiavis by reading our dedicated tutorials:

  • Camera Capture Guide: Learn about device enumeration, hardware acceleration, and frame reading.
  • Image Processing Guide: Learn how the internal NV12/YUY2 to RGB conversions work, and how to apply annotations.
  • Video Export Guide: Learn how to use CaptureSession to record JPEG sequences and export them to MP4.

💡 Examples

We provide heavily-commented, practical examples to get you started quickly. Run them using cargo:

cargo run --release --example camera_preview
cargo run --release --example save_image
cargo run --release --example image_processing
cargo run --release --example list_cameras

(Note: High-resolution software pixel conversions are CPU-intensive. It is recommended to run camera examples in --release mode for a smooth 30+ FPS experience).


License

This project is licensed under the Apache License 2.0.