Obb

Struct Obb 

Source
pub struct Obb { /* private fields */ }
Expand description

Oriented bounding box with four vertices and metadata.

Implementations§

Source§

impl Obb

Source

pub fn with_vertices(self, x: [[f32; 2]; 4]) -> Self

Sets the vertices field.

§Arguments
  • x - The new value to be assigned
§Returns

Returns Self for method chaining.

§Example
let obj = Obb::default().with_vertices(value);

Generated by aksr - Builder pattern macro

Source

pub fn vertices(&self) -> &[[f32; 2]; 4]

Returns a reference to the vertices field.

§Example
let obj = Obb::default();
let value = obj.vertices();

Generated by aksr - Builder pattern macro

Source

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 used

Generated by aksr - Builder pattern macro

Source

pub fn with_meta(self, x: InstanceMeta) -> Self

Sets the meta field.

§Arguments
  • x - The new value to be assigned
§Returns

Returns Self for method chaining.

§Example
let obj = Obb::default().with_meta(value);

Generated by aksr - Builder pattern macro

Source

pub fn meta(&self) -> &InstanceMeta

Returns a reference to the meta field.

§Example
let obj = Obb::default();
let value = obj.meta();

Generated by aksr - Builder pattern macro

Source

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 used

Generated by aksr - Builder pattern macro

Source

pub fn with_style(self, x: ObbStyle) -> Self

Sets the optional style field.

§Arguments
  • x - The value that will be automatically wrapped in Some
§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

Source

pub fn style(&self) -> Option<&ObbStyle>

Returns an optional reference to the style field.

§Example
let obj = Obb::default();
let value = obj.style();

Generated by aksr - Builder pattern macro

Source

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 containing the field value, or None if the field was None.

§Example
let obj = Obb::default().with_style(value);
let value = obj.into_style();

Generated by aksr - Builder pattern macro

Source

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 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_style(value);
let value = obj.take_style();
// obj.style is now None

Generated by aksr - Builder pattern macro

Source

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 in Some
§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

Source

pub fn keypoints(&self) -> Option<&[Keypoint]>

Returns an optional slice view of the keypoints field.

§Example
let obj = Obb::default();
let items = obj.keypoints();

Generated by aksr - Builder pattern macro

Source

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

Source

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 None

Generated by aksr - Builder pattern macro

Source§

impl Obb

Source

pub fn with_track_id(self, track_id: usize) -> Self

Source

pub fn track_id(&self) -> Option<usize>

Source

pub fn with_uid(self, uid: usize) -> Self

Source

pub fn with_id(self, id: usize) -> Self

Source

pub fn with_name(self, name: &str) -> Self

Source

pub fn with_confidence(self, confidence: f32) -> Self

Source

pub fn uid(&self) -> usize

Source

pub fn name(&self) -> Option<&str>

Source

pub fn confidence(&self) -> Option<f32>

Source

pub fn id(&self) -> Option<usize>

Source

pub fn from_cxcywhd(cx: f32, cy: f32, w: f32, h: f32, d: f32) -> Self

Build from (cx, cy, width, height, degrees)

Source

pub fn from_cxcywhr(cx: f32, cy: f32, w: f32, h: f32, r: f32) -> Self

Build from (cx, cy, width, height, radians)

Source

pub fn coords(&self) -> &[[f32; 2]; 4]

Get the 4 vertices as slice (CCW ordered, starting from bottom-left)

Source

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

Source

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).

Source

pub fn top(&self) -> [f32; 2]

Get the topmost point (minimum y coordinate)

Source

pub fn left(&self) -> [f32; 2]

Get the leftmost point (minimum x coordinate)

Source

pub fn bottom(&self) -> [f32; 2]

Get the bottommost point (maximum y coordinate)

Source

pub fn right(&self) -> [f32; 2]

Get the rightmost point (maximum x coordinate)

Source

pub fn to_polygon(&self) -> Polygon

Convert to Polygon with metadata

Source

pub fn area(&self) -> f32

Calculate area directly using Shoelace formula

Source

pub fn intersect(&self, other: &Self) -> f32

Calculate intersection area with another OBB using optimized Sutherland-Hodgman

Source

pub fn union(&self, other: &Self) -> f32

Source

pub fn iou(&self, other: &Self) -> f32

Trait Implementations§

Source§

impl Clone for Obb

Source§

fn clone(&self) -> Obb

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Obb

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Obb

Source§

fn default() -> Obb

Returns the “default value” for a type. Read more
Source§

impl Drawable for Obb

Source§

fn draw(&self, ctx: &DrawContext<'_>, canvas: &mut RgbaImage) -> Result<()>

Source§

impl From<[[f32; 2]; 4]> for Obb

Source§

fn from(vertices: [[f32; 2]; 4]) -> Self

Converts to this type from the input type.
Source§

impl From<Obb> for [[f32; 2]; 4]

Source§

fn from(obb: Obb) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<[f32; 2]>> for Obb

Source§

fn from(vertices: Vec<[f32; 2]>) -> Self

Converts to this type from the input type.
Source§

impl HasIoU for Obb

Source§

fn iou(&self, other: &Self) -> f32

Calculates IoU with another object.
Source§

impl HasScore for Obb

Source§

fn score(&self) -> f32

Returns the confidence score.
Source§

impl PartialEq for Obb

Source§

fn eq(&self, other: &Obb) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,