Crates.io | rusty-vision |
lib.rs | rusty-vision |
version | 0.0.4 |
source | src |
created_at | 2024-10-21 14:00:19.828918 |
updated_at | 2024-10-25 17:14:24.950345 |
description | A basic Image manipulation library. |
homepage | https://github.com/marmikshah/rusty-vision |
repository | https://github.com/marmikshah/rusty-vision |
max_upload_size | |
id | 1417538 |
size | 57,528 |
:bangbang: NOTE: This is purely experimental and is not intended to be used in production.
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.
Add this to your Cargo.toml
:
[dependencies]
rusty-vision = "0.0.0"
or directly run
cargo add rusty-vision
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();