3 releases
0.0.4 | Oct 25, 2024 |
---|---|
0.0.1 | Oct 21, 2024 |
0.0.0 | Oct 21, 2024 |
#263 in Images
38KB
886 lines
Rusty Vision
‼️ NOTE: This is purely experimental and is not intended to be used in production.
Overview
A basic image processing and manipulation library with the aim to provide OpenCV like functions in Rust.
🚧 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();
Dependencies
~0.5–1MB
~22K SLoC