broken(retinaface): Added drawing for bounding box
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -211,7 +211,7 @@ dependencies = [
|
||||
"bitflags 2.9.1",
|
||||
"cexpr",
|
||||
"clang-sys",
|
||||
"itertools 0.13.0",
|
||||
"itertools 0.12.1",
|
||||
"log",
|
||||
"prettyplease",
|
||||
"proc-macro2",
|
||||
|
||||
12
Cargo.toml
12
Cargo.toml
@@ -6,21 +6,21 @@ version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[patch."https://github.com/uttarayan21/mnn-rs"]
|
||||
mnn = { path = "/Users/fs0c131y/Projects/aftershoot/mnn-rs" }
|
||||
mnn = { path = "/home/servius/Projects/mnn-rs" }
|
||||
|
||||
[workspace.dependencies]
|
||||
ndarray-image = { path = "ndarray-image" }
|
||||
ndarray-resize = { path = "ndarray-resize" }
|
||||
mnn = { git = "https://github.com/uttarayan21/mnn-rs", version = "0.2.0", features = [
|
||||
"metal",
|
||||
"coreml",
|
||||
"tracing",
|
||||
# "metal",
|
||||
# "coreml",
|
||||
"tracing",
|
||||
], branch = "restructure-tensor-type" }
|
||||
mnn-bridge = { git = "https://github.com/uttarayan21/mnn-rs", version = "0.1.0", features = [
|
||||
"ndarray",
|
||||
"ndarray",
|
||||
], branch = "restructure-tensor-type" }
|
||||
mnn-sync = { git = "https://github.com/uttarayan21/mnn-rs", version = "0.1.0", features = [
|
||||
"tracing",
|
||||
"tracing",
|
||||
], branch = "restructure-tensor-type" }
|
||||
|
||||
[package]
|
||||
|
||||
@@ -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