Skip to main content

FloatDetectorContext

Struct FloatDetectorContext 

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

Shi-Tomasi corner detector for f32 images in physical units, e.g. thermal frames in °C. The counterpart of DetectorContext, owning every buffer it touches.

The pipeline matches the 8-bit detector: Scharr gradients, the mean 3x3 structure tensor, its minimum eigenvalue, 3x3 non-maximum suppression, sorting and spacing. Gradients are computed in f32 and the tensor is summed in f64, so neither quantization nor cancellation limits weak structure. For an image whose values are integers, the result equals the 8-bit detector’s on the same values bit for bit, as long as the tensor determinant stays below 2^53, which holds for all but extreme 8-bit contrast. See ScoreThreshold for the score unit and the threshold.

Conventions, shared with the 8-bit detector:

  • Border pixels have zero gradient but count as window samples, and the outermost pixels are never returned.
  • A pixel is a local maximum when no 8-neighbor scores higher, so equal neighbors on a plateau are all kept.
  • Results are sorted by descending score, then by row, then by column.

Buffers grow on demand and are reused. Create the context with with_capacity to keep allocation out of the per-frame path; calls within the DetectorCapacity then perform no heap allocation, whatever the image content.

Implementations§

Source§

impl FloatDetectorContext

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: FloatImageView<'_>, threshold: ScoreThreshold, min_distance: u32, ) -> &[Corner]

Detects corners scoring at least threshold, at least min_distance pixels apart (zero disables spacing), greedily by descending score.

Returns Corners from the context’s own result buffer; the slice is valid until the next call. Images narrower or shorter than three pixels, and flat images, yield no corners.

Source

pub fn detect_grid( &mut self, image: FloatImageView<'_>, grid: Grid, threshold: ScoreThreshold, min_distance: u32, existing_points: &[(f32, f32)], ) -> &[Corner]

Detects up to grid.max_per_cell corners per cell of grid, counting existing_points against each cell’s budget and keeping min_distance to them, as good_features_to_track_grid does.

§Panics

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

Trait Implementations§

Source§

impl Default for FloatDetectorContext

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.