feat: added some post processing for retinaface
This commit is contained in:
39
bounding-box/src/draw.rs
Normal file
39
bounding-box/src/draw.rs
Normal file
@@ -0,0 +1,39 @@
|
||||
use crate::*;
|
||||
pub use color::Rgba8;
|
||||
|
||||
use ndarray::{Array3, ArrayViewMut3};
|
||||
|
||||
pub trait Draw<T> {
|
||||
fn draw(&mut self, item: T, color: color::Rgba8, thickness: usize);
|
||||
}
|
||||
|
||||
// impl<T: Drawable<Self>> Draw<T> for Array3<u8> {
|
||||
// fn draw(&self, item: T, color: color::Rgba8, thickness: usize) {
|
||||
// item.draw(&self, color, thickness);
|
||||
// }
|
||||
// }
|
||||
|
||||
pub trait Drawable<Canvas, T> {
|
||||
fn draw(&self, canvas: &mut Canvas, color: color::Rgba8, thickness: T);
|
||||
}
|
||||
|
||||
/// Implementing Drawable for Aabb2 with Array3<u8> as the canvas type
|
||||
/// Assuming Array3<u8> is a 3D array representing an image with RGB/RGBA channels
|
||||
impl<T> Drawable<ArrayViewMut3<'_, u8>, T> for Aabb2<T>
|
||||
where
|
||||
T: Num + core::ops::SubAssign + core::ops::AddAssign + core::ops::DivAssign,
|
||||
T: PartialOrd,
|
||||
{
|
||||
fn draw(&self, canvas: &mut ArrayViewMut3<u8>, color: color::Rgba8, thickness: T) {
|
||||
use itertools::Itertools;
|
||||
let (height, width, channels) = canvas.dim();
|
||||
self.corners()
|
||||
.iter()
|
||||
.zip(self.padding(thickness).corners())
|
||||
.tuple_windows()
|
||||
.for_each(|((a, b), (c, d))| {
|
||||
let bbox = Aabb2::from_vertices([*a, b, *c, d]);
|
||||
todo!();
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user