Skip to main content

DetectorContext

Struct DetectorContext 

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

Reusable owner of every buffer the Shi-Tomasi detector touches: gradient planes, structure-tensor row buffers, the score plane, the candidate list, the spacing grid and the result vector.

Keep one per detection thread and call detect or detect_grid each time. Buffers grow on demand and are reused. To keep allocation out of the per-frame path, create the context with with_capacity: calls within its DetectorCapacity then perform no heap allocation, whatever the image content. Without a reservation, the first call allocates, and a later image with more candidates than any before can still grow a buffer. The free functions good_features_to_track and good_features_to_track_grid create a context per call.

Implementations§

Source§

impl DetectorContext

Source

pub fn new() -> Self

Creates an empty context. Buffers grow to fit on the first detection and are reused thereafter.

Source

pub fn with_capacity(capacity: DetectorCapacity) -> Self

Creates a context with every buffer allocated for capacity.

Source

pub fn reserve(&mut self, capacity: DetectorCapacity)

Allocates every buffer for capacity now, so that later calls within it do not allocate. Existing capacity is kept.

Source

pub fn detect( &mut self, image: &GrayImage, quality_level: f32, min_distance: u32, ) -> &[Corner]

Detects corners as good_features_to_track does, returning them from the context’s own result buffer. The slice is valid until the next call.

Source

pub fn detect_grid( &mut self, image: &GrayImage, grid: Grid, quality_level: f32, min_distance: u32, existing_points: &[(f32, f32)], ) -> &[Corner]

Detects corners per grid cell as good_features_to_track_grid does, returning them from the context’s own result buffer. The slice is valid until the next call.

§Panics

Panics if grid.cols or grid.rows is zero.

Trait Implementations§

Source§

impl Default for DetectorContext

Source§

fn default() -> Self

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

Auto Trait Implementations§

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.