broken(retinaface): Added drawing for bounding box

This commit is contained in:
uttarayan21
2025-08-05 02:10:14 +05:30
parent 9fd0993cc3
commit 74c603dc37
4 changed files with 26 additions and 20 deletions

View File

@@ -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);
});
});
}
}