benchmarks comparing the rust image processing ecosystem
Diffstat (limited to 'benches/blur.rs')
-rw-r--r--benches/blur.rs33
1 files changed, 32 insertions, 1 deletions
diff --git a/benches/blur.rs b/benches/blur.rs
index a126a74..211dc9d 100644
--- a/benches/blur.rs
+++ b/benches/blur.rs
@@ -1,9 +1,40 @@
#![feature(array_chunks)]
use fimg::Image;
use image::RgbImage;
+use opencv::{core::CV_8UC3, prelude::*};
const SIZE: u32 = 1356;
+pub fn opencv() {
+ opencv::core::set_num_threads(1).unwrap();
+ let mut data = iai::black_box(include_bytes!("../small_data.imgbuf").to_vec())
+ .array_chunks::<3>()
+ .flat_map(|&[r, g, b]| [b, g, r])
+ .collect::<Vec<_>>();
+ let mut o = unsafe { Mat::new_rows_cols(SIZE as i32, SIZE as i32, CV_8UC3).unwrap() };
+ opencv::imgproc::gaussian_blur_def(
+ &unsafe {
+ Mat::new_size_with_data_def(
+ opencv::core::Size_ {
+ width: SIZE as i32,
+ height: SIZE as i32,
+ },
+ CV_8UC3,
+ data.as_mut_ptr() as *mut core::ffi::c_void,
+ )
+ .unwrap()
+ },
+ &mut o,
+ opencv::core::Size_ {
+ width: 0,
+ height: 0,
+ },
+ 15.0,
+ )
+ .unwrap();
+ iai::black_box(&o);
+}
+
pub fn imageproc() {
iai::black_box(&imageproc::filter::gaussian_blur_f32(
&RgbImage::from_raw(
@@ -65,4 +96,4 @@ pub fn fimg() {
iai::black_box(&i);
}
-iai::main!(blud, imageproc, fimg, image, fastblur);
+iai::main!(blud, imageproc, fimg, image, fastblur, opencv);