Crates.io | mat2image |
lib.rs | mat2image |
version | 0.2.0 |
source | src |
created_at | 2022-08-12 22:03:13.131658 |
updated_at | 2022-11-22 15:20:26.317604 |
description | Utilities to convert opencv::Mat to image::DynamicImage |
homepage | |
repository | https://github.com/rcastill/mat2image |
max_upload_size | |
id | 644286 |
size | 39,199 |
Rust crate that exposes ToImage
trait.
It implements ToImage
for
Mat to convert it
into DynamicImage.
It also exposes ToImageUnsafe
. The rationale behind this, comes after learning
through profiling that
Mat::iter
is painfully slow. Then Mat::to_image_unsafe
is implemented using
Mat::data
accessing the raw data.
This example reads an image (examples/tinta_helada.jpg) using opencv and saves it using image API.
cargo run --release --example save_as [output_name[.jpg]=out.jpg]
When noticing that to_image
takes too much time, I profiled using perf
and
visualized it with Firefox Profiler.
Full profiling:
# build example with debug symbols
cargo build --example save_as
# record perf data
# sudo because of `paranoid` kernel setting
sudo perf record -g -F 999 ./target/debug/examples/save_as
# convert output to firefox readable type
sudo perf script -F +pid >save_as.perf
Then load it in Firefox Profiler.
References