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
impl DetectorContext
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: &GrayImage,
quality_level: f32,
min_distance: u32,
) -> &[Corner]
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.
Sourcepub fn detect_grid(
&mut self,
image: &GrayImage,
grid: Grid,
quality_level: f32,
min_distance: u32,
existing_points: &[(f32, f32)],
) -> &[Corner]
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.