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
impl FloatDetectorContext
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates an empty context. Buffers grow to fit on the first detection and are reused thereafter.
Sourcepub fn with_capacity(capacity: DetectorCapacity) -> Self
pub fn with_capacity(capacity: DetectorCapacity) -> Self
Creates a context with every buffer allocated for capacity.
Sourcepub fn reserve(&mut self, capacity: DetectorCapacity)
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.
Sourcepub fn detect(
&mut self,
image: FloatImageView<'_>,
threshold: ScoreThreshold,
min_distance: u32,
) -> &[Corner]
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.
Sourcepub fn detect_grid(
&mut self,
image: FloatImageView<'_>,
grid: Grid,
threshold: ScoreThreshold,
min_distance: u32,
existing_points: &[(f32, f32)],
) -> &[Corner]
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.