broken(retinaface): Added drawing for bounding box
This commit is contained in:
@@ -45,21 +45,26 @@ impl Drawable<ArrayViewMut3<'_, u8>> for Aabb2<usize> {
|
||||
|
||||
impl Drawable<Array3<u8>> for Aabb2<usize> {
|
||||
fn draw(&self, canvas: &mut Array3<u8>, color: color::Rgba8, thickness: usize) {
|
||||
use itertools::Itertools;
|
||||
// let (height, width, channels) = canvas.dim();
|
||||
let color = Array1::from_vec(vec![color.r, color.g, color.b, color.a]);
|
||||
let pixel_size = canvas.dim().2;
|
||||
let color = color.slice(ndarray::s![..pixel_size]);
|
||||
let [x1y1, x2y1, x1y2, x2y2] = self.corners();
|
||||
let right = Aabb2::from_x1y1x2y2(x1y1.x, x1y1.y, x2y1.x, x2y1.y + thickness);
|
||||
dbg!(right);
|
||||
canvas
|
||||
.roi_mut(right)
|
||||
.expect("Failed to get ROI")
|
||||
.lanes_mut(ndarray::Axis(2))
|
||||
.into_iter()
|
||||
.for_each(|mut pixel| {
|
||||
pixel.assign(&color);
|
||||
});
|
||||
dbg!(self.corners());
|
||||
let top = Aabb2::from_x1y1x2y2(x1y1.x, x1y1.y, x2y1.x, x2y1.y + thickness);
|
||||
let bottom = Aabb2::from_x1y1x2y2(x2y2.x, x2y2.y, x1y2.x, x1y2.y + thickness);
|
||||
let left = Aabb2::from_x1y1x2y2(x1y1.x, x1y1.y, x1y2.x + thickness, x1y2.y);
|
||||
// let right = Aabb2::from_x1y1x2y2(x2y2.x, x2y2.y, x2y1.x + thickness, x2y1.y);
|
||||
let lines = [top, bottom, left /* right */];
|
||||
lines.into_iter().for_each(|line| {
|
||||
dbg!(line);
|
||||
canvas
|
||||
.roi_mut(line)
|
||||
.expect("Failed to get Roi")
|
||||
.lanes_mut(ndarray::Axis(2))
|
||||
.into_iter()
|
||||
.for_each(|mut pixel| {
|
||||
pixel.assign(&color);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,12 +235,13 @@ impl<T: Num, const D: usize> AxisAlignedBoundingBox<T, D> {
|
||||
}
|
||||
|
||||
impl<T: Num> Aabb2<T> {
|
||||
pub fn from_x1y1x2y2(x1: T, x2: T, y1: T, y2: T) -> Self
|
||||
pub fn from_x1y1x2y2(x1: T, y1: T, x2: T, y2: T) -> Self
|
||||
where
|
||||
T: core::ops::SubAssign,
|
||||
{
|
||||
let point1 = Point2::new(x1, y1);
|
||||
let point2 = Point2::new(x2, y2);
|
||||
dbg!(point1, point2);
|
||||
Self::from_min_max_vertices(point1, point2)
|
||||
}
|
||||
pub fn new_2d(point1: Point2<T>, point2: Point2<T>) -> Self
|
||||
|
||||
Reference in New Issue
Block a user