feat(bounding-box): add scale_uniform method for consistent scaling
feat(gui): display face ROIs in comparison results refactor(bridge): pad detected face bounding boxes uniformly
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user