jerry73204/rust-cv-convert

Some documentation needed.

Barafu opened this issue · 2 comments

At least some examples are needed. I can not understand how to use this crate convert Rust image into opencv, for example.

I just made a PR #5, hope this would help you.

You can convert the Rust image to opencv Mat by, for example,

use anyhow::Result;
use cv_convert::{TryFromCv, TryIntoCv};
use opencv::{self as cv, highgui, imgcodecs};

fn main() -> Result<()> {
    let path = "YOUR_IMAGE_PATH";
    let img = image::io::Reader::open(&path)?.decode()?;
    let mat: cv::core::Mat = img.try_into_cv()?;
    highgui::imshow("Image-to-OpenCV", &mat)?;
    highgui::wait_key(0)?;
    Ok(())
}

Now the API doc (link) includes a working example.