pub struct Obb { /* private fields */ }Expand description
Oriented bounding box with four vertices and metadata.
Implementations§
Source§impl Obb
impl Obb
Sourcepub fn with_vertices(self, x: [[f32; 2]; 4]) -> Self
pub fn with_vertices(self, x: [[f32; 2]; 4]) -> Self
Sourcepub fn into_vertices(self) -> [[f32; 2]; 4]
pub fn into_vertices(self) -> [[f32; 2]; 4]
Consumes self and returns the vertices field.
This method moves the owned value out of the struct without cloning.
§Returns
Returns the owned value of type [[f32; 2]; 4].
§Example
let obj = Obb::default().with_vertices(value);
let value = obj.into_vertices();
// obj is now consumed and cannot be usedGenerated by aksr - Builder pattern macro
Sourcepub fn with_meta(self, x: InstanceMeta) -> Self
pub fn with_meta(self, x: InstanceMeta) -> Self
Sourcepub fn meta(&self) -> &InstanceMeta
pub fn meta(&self) -> &InstanceMeta
Sourcepub fn into_meta(self) -> InstanceMeta
pub fn into_meta(self) -> InstanceMeta
Consumes self and returns the meta field.
This method moves the owned value out of the struct without cloning.
§Returns
Returns the owned value of type InstanceMeta.
§Example
let obj = Obb::default().with_meta(value);
let value = obj.into_meta();
// obj is now consumed and cannot be usedGenerated by aksr - Builder pattern macro
Sourcepub fn with_style(self, x: ObbStyle) -> Self
pub fn with_style(self, x: ObbStyle) -> Self
Sets the optional style field.
§Arguments
x- The value that will be automatically wrapped inSome
§Returns
Returns Self for method chaining.
§Note
The value is automatically wrapped in Some, so you don’t need to pass Some(value).
§Example
let obj = Obb::default().with_style(value);Generated by aksr - Builder pattern macro
Sourcepub fn into_style(self) -> Option<ObbStyle>
pub fn into_style(self) -> Option<ObbStyle>
Consumes self and returns the style field.
This method moves the owned value out of the struct without cloning.
§Returns
Returns Option
§Example
let obj = Obb::default().with_style(value);
let value = obj.into_style();Generated by aksr - Builder pattern macro
Sourcepub fn take_style(&mut self) -> Option<ObbStyle>
pub fn take_style(&mut self) -> Option<ObbStyle>
Takes the style field, leaving None in its place.
This method moves the value out and replaces it with None, allowing you to continue using the struct.
§Returns
Returns Option
§Note
This does not require the inner type to implement Default.
§Example
let mut obj = Obb::default().with_style(value);
let value = obj.take_style();
// obj.style is now NoneGenerated by aksr - Builder pattern macro
Sourcepub fn with_keypoints(self, x: &[Keypoint]) -> Self
pub fn with_keypoints(self, x: &[Keypoint]) -> Self
Sets the optional keypoints field from a slice.
§Arguments
x- A slice of elements that will be automatically converted to a vector and wrapped inSome
§Returns
Returns Self for method chaining.
§Note
If the slice is empty, the field remains unchanged. Otherwise, it’s automatically converted to Vec and wrapped in Some.
§Example
let obj = Obb::default().with_keypoints(&[item1, item2]);Generated by aksr - Builder pattern macro
Sourcepub fn into_keypoints(self) -> Option<Vec<Keypoint>>
pub fn into_keypoints(self) -> Option<Vec<Keypoint>>
Consumes self and returns the keypoints field.
This method moves the owned value out of the struct without cloning.
§Returns
Returns Option<Vec < Keypoint >> containing the field value, or None if the field was None.
§Example
let obj = Obb::default().with_keypoints(value);
let value = obj.into_keypoints();Generated by aksr - Builder pattern macro
Sourcepub fn take_keypoints(&mut self) -> Option<Vec<Keypoint>>
pub fn take_keypoints(&mut self) -> Option<Vec<Keypoint>>
Takes the keypoints field, leaving None in its place.
This method moves the value out and replaces it with None, allowing you to continue using the struct.
§Returns
Returns Option<Vec < Keypoint >> containing the field value, or None if the field was None.
§Note
This does not require the inner type to implement Default.
§Example
let mut obj = Obb::default().with_keypoints(value);
let value = obj.take_keypoints();
// obj.keypoints is now NoneGenerated by aksr - Builder pattern macro
Source§impl Obb
impl Obb
pub fn with_track_id(self, track_id: usize) -> Self
pub fn track_id(&self) -> Option<usize>
pub fn with_uid(self, uid: usize) -> Self
pub fn with_id(self, id: usize) -> Self
pub fn with_name(self, name: &str) -> Self
pub fn with_confidence(self, confidence: f32) -> Self
pub fn uid(&self) -> usize
pub fn name(&self) -> Option<&str>
pub fn confidence(&self) -> Option<f32>
pub fn id(&self) -> Option<usize>
Sourcepub fn from_cxcywhd(cx: f32, cy: f32, w: f32, h: f32, d: f32) -> Self
pub fn from_cxcywhd(cx: f32, cy: f32, w: f32, h: f32, d: f32) -> Self
Build from (cx, cy, width, height, degrees)
Sourcepub fn from_cxcywhr(cx: f32, cy: f32, w: f32, h: f32, r: f32) -> Self
pub fn from_cxcywhr(cx: f32, cy: f32, w: f32, h: f32, r: f32) -> Self
Build from (cx, cy, width, height, radians)
Sourcepub fn coords(&self) -> &[[f32; 2]; 4]
pub fn coords(&self) -> &[[f32; 2]; 4]
Get the 4 vertices as slice (CCW ordered, starting from bottom-left)
Sourcepub fn is_hbb(&self) -> bool
pub fn is_hbb(&self) -> bool
Check if this OBB is axis-aligned (i.e., it’s actually an Hbb) Returns true if all edges are parallel to x or y axis
Sourcepub fn tlbr(&self) -> [[f32; 2]; 4]
pub fn tlbr(&self) -> [[f32; 2]; 4]
Get [top-left, top-right, bottom-right, bottom-left] corners for Hbb Or [top, left, bottom, right] extreme points for rotated OBB
For axis-aligned rectangles (Hbb), returns 4 distinct corner points. For rotated OBB, returns extreme points (some may coincide at corners).
Sourcepub fn to_polygon(&self) -> Polygon
pub fn to_polygon(&self) -> Polygon
Convert to Polygon with metadata
Sourcepub fn intersect(&self, other: &Self) -> f32
pub fn intersect(&self, other: &Self) -> f32
Calculate intersection area with another OBB using optimized Sutherland-Hodgman
pub fn union(&self, other: &Self) -> f32
pub fn iou(&self, other: &Self) -> f32
Trait Implementations§
impl StructuralPartialEq for Obb
Auto Trait Implementations§
impl Freeze for Obb
impl RefUnwindSafe for Obb
impl Send for Obb
impl Sync for Obb
impl Unpin for Obb
impl UnwindSafe for Obb
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.