feat(bounding-box): add scale_uniform method for consistent scaling
Some checks failed
build / checks-matrix (push) Successful in 19m22s
build / codecov (push) Failing after 19m26s
docs / docs (push) Failing after 28m51s
build / checks-build (push) Has been cancelled

feat(gui): display face ROIs in comparison results

refactor(bridge): pad detected face bounding boxes uniformly
This commit is contained in:
uttarayan21
2025-08-22 19:01:34 +05:30
parent c758fd8d41
commit 3eec262076
3 changed files with 180 additions and 18 deletions

View File

@@ -163,6 +163,21 @@ impl<T: Num, const D: usize> AxisAlignedBoundingBox<T, D> {
}
}
pub fn scale_uniform(self, scalar: T) -> Self
where
T: core::ops::MulAssign,
T: core::ops::DivAssign,
T: core::ops::SubAssign,
{
let two = T::one() + T::one();
let new_size = self.size * scalar;
let new_point = self.point.coords - (new_size - self.size) / two;
Self {
point: Point::from(new_point),
size: new_size,
}
}
pub fn contains_bbox(&self, other: &Self) -> bool
where
T: core::ops::AddAssign,
@@ -270,15 +285,17 @@ impl<T: Num, const D: usize> AxisAlignedBoundingBox<T, D> {
})
}
// pub fn as_<T2>(&self) -> Option<Aabb<T2, D>>
// where
// T2: Num + simba::scalar::SubsetOf<T>,
// {
// Some(Aabb {
// point: Point::from(self.point.coords.as_()),
// size: self.size.as_(),
// })
// }
pub fn as_<T2>(&self) -> Aabb<T2, D>
where
T2: Num,
T: num::cast::AsPrimitive<T2>,
{
Aabb {
point: Point::from(self.point.coords.map(|x| x.as_())),
size: self.size.map(|x| x.as_()),
}
}
pub fn measure(&self) -> T
where
T: core::ops::MulAssign,