feat: Draw bounding boxes correctly

This commit is contained in:
uttarayan21
2025-08-05 12:58:17 +05:30
parent 74c603dc37
commit bcb7c94390
4 changed files with 34 additions and 12 deletions

View File

@@ -48,15 +48,13 @@ impl Drawable<Array3<u8>> for Aabb2<usize> {
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();
dbg!(self.corners());
let [x1y1, x2y1, x2y2, x1y2] = 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 bottom = Aabb2::from_x1y1x2y2(x1y2.x, x1y2.y, x2y2.x, x2y2.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 */];
let right = Aabb2::from_x1y1x2y2(x2y1.x, x2y1.y, x2y2.x + thickness, x2y2.y + thickness);
let lines = [top, bottom, left, right];
lines.into_iter().for_each(|line| {
dbg!(line);
canvas
.roi_mut(line)
.expect("Failed to get Roi")