rusty-vision

Crates.iorusty-vision
lib.rsrusty-vision
version0.0.4
sourcesrc
created_at2024-10-21 14:00:19.828918
updated_at2024-10-25 17:14:24.950345
descriptionA basic Image manipulation library.
homepagehttps://github.com/marmikshah/rusty-vision
repositoryhttps://github.com/marmikshah/rusty-vision
max_upload_size
id1417538
size57,528
Marmik Shah (marmikshah)

documentation

README

Rusty Vision

:bangbang: NOTE: This is purely experimental and is not intended to be used in production.

Crates.io Docs.rs Build Status

Overview

A basic image processing and manipulation library with the aim to provide OpenCV like functions in Rust.

:construction: NOTE: Since the repo is still in very early phase, please expect breaking changes with new releases.

Features

  • (WIP) Image Compression & Decompression.
  • (WIP) Drawing Shapes.
  • (WIP) Image Cropping & Resising.
  • (TODO) Background Subtraction.
  • (TODO) Optical Flow.
  • (Future Plan) HW Accelerated Image Operations.

Installation

Add this to your Cargo.toml:

[dependencies]
rusty-vision = "0.0.0"

or directly run

cargo add rusty-vision

Usage

Import the core Image module and basic traits

Full code at draw-rect.rs.

// Core Image Structure and its traits
use rv::image::Image;
use rv::traits::*;

// Useful structures for geometric operations
use rv::geometry::{Point, Shape};

// Structures and Implenetations for Colors and Channels.
use rv::color::{Color, ColorSpace};

// Image Encoding/Decoding
use rv::codec::Codex;
use rv::io::writer::Writer;

Create a blank image with black background.

let mut image = Image::new(
    Shape {
        width: 1920,
        height: 1080,
        ndim: 3,
    },
    ColorSpace::RGB,
);

Draw a rect using the Drawable trait.

let config = RectParams::new(
    Point { x: 10, y: 10 },
    Shape {
        width: 100,
        height: 100,
        ndim: 1,
    },
    Color::new(20, 150, 20, 1.0),
    Some(10),
    Some(0.0),
    None,
);

// Draw
image.draw(&config).unwrap();

Save as PNG (Currently only PNG supported)

// NOTE: `unwrap` can panic
image.write("output.png".to_string(), Codex::PNG).unwrap();
Commit count: 35

cargo fmt