Skip to main content

Detector

Struct Detector 

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

High-level chessboard-corner detector.

Owns the pyramid and detector-specific scratch buffers so the caller can reuse them across successive frames.

Implementations§

Source§

impl Detector

Source

pub fn new(cfg: DetectorConfig) -> Result<Self, ChessError>

Build a detector with the given config.

§Errors

Returns ChessError::Upscale when the DetectorConfig::upscale configuration is invalid.

Source

pub fn with_default() -> Self

Build a detector with the default config.

Source

pub fn config(&self) -> &DetectorConfig

Borrow the active config.

Source

pub fn set_config(&mut self, cfg: DetectorConfig) -> Result<(), ChessError>

Replace the active config.

§Errors

Returns ChessError::Upscale when the new config’s upscale section is invalid.

Source

pub fn detect_u8( &mut self, img: &[u8], width: u32, height: u32, ) -> Result<Vec<CornerDescriptor>, ChessError>

Detect chessboard corners from a raw 8-bit grayscale buffer.

§Errors

Returns ChessError::DimensionMismatch if img.len() != width * height. Returns ChessError::Upscale if the upscale configuration becomes invalid (this should not normally happen — Detector::new / Detector::set_config validate up-front).

Source

pub fn detect( &mut self, img: &GrayImage, ) -> Result<Vec<CornerDescriptor>, ChessError>

Detect chessboard corners from an [image::GrayImage].

§Errors

Returns ChessError::Upscale if the upscale configuration becomes invalid.

Source

pub fn detect_u8_roi( &mut self, img: &[u8], width: u32, height: u32, roi: Roi, ) -> Result<Vec<CornerDescriptor>, ChessError>

Detect chessboard corners inside a rectangular region roi of a raw 8-bit grayscale image.

Returns the corners whose detected peak lies inside roi, each refined and described exactly as Detector::detect_u8 would: the same configured refiner and the same orientation/descriptor stage. Coordinates are in the full input-image pixel frame. Both detection strategies (ChESS and Radon) are supported.

§Single-scale only

ROI detection is single-scale local detection by definition: the multiscale and upscale sections of the active config do not apply on this path. For whole-image detection — including the coarse-to-fine pyramid and the pre-pipeline upscaling stage — use Detector::detect_u8 / Detector::detect.

§ROI clamping

A roi extending past the image is clamped to the image bounds (matching the multiscale ROI-carving behaviour). A fully out-of-range or degenerate post-clamp roi returns Ok(vec![]), not an error.

§Parity with detect_u8

Parity is defined against a single-scale, non-upscaled Detector::detect_u8 run — multiscale set to SingleScale and upscale disabled, as in the DetectorConfig::chess and DetectorConfig::radon presets. When a pyramid or upscale section is active, detect_u8 detects on resampled images that this path never builds, so its output is not comparable corner-for-corner.

Against that run, every ChESS corner whose peak lies more than ring_radius + nms_radius pixels inside the clamped roi (on every side) is returned here with a bit-identical response and a position that agrees to within floating-point rounding (well under 1e-3 px). The integer peak detection is exact; only the sub-pixel refinement rounds differently, because it runs in the ROI-local coordinate frame — the same numerical relationship a coarse-to-fine multiscale run has to a full-frame single-scale run. The Radon strategy recomputes its response over the carved patch (prefix-sum accumulation restarts at the patch origin), so its parity is approximate: interior corners reappear, but response values and subpixel positions carry a small floating-point drift rather than being bit-exact. Corners nearer the ROI edge — or nearer than the detector support to the image border — may differ or be absent under either strategy.

§Errors

Returns ChessError::DimensionMismatch if img.len() != width * height. With the ml-refiner feature, returns ChessError::RoiRefinerUnsupported when the configuration selects the ML refiner: the ML refiner runs a whole-frame model pipeline this path does not carry, and the refiner selection is never silently downgraded — use Detector::detect_u8 for ML refinement.

Source

pub fn detect_roi( &mut self, img: &GrayImage, roi: Roi, ) -> Result<Vec<CornerDescriptor>, ChessError>

Detect chessboard corners inside a rectangular region roi of an [image::GrayImage].

See Detector::detect_u8_roi for the ROI contract, the single-scale caveat, the clamping behaviour, and the parity guarantee.

§Errors

Same as Detector::detect_u8_roi.

Source

pub fn diagnostics(&self) -> DetectorDiagnostics<'_>

Borrow a detector-bound diagnostics accessor.

The returned DetectorDiagnostics exposes intermediate detector outputs — the dense ChESS response map and the Radon heatmap — sourced from this detector’s already-configured DetectorConfig, so a caller holding a configured Detector need not re-supply a config to obtain diagnostic data.

This is the detector-bound half of the diagnostics channel; the free functions in crate::diagnostics serve stateless callers. Both share the same opt-in, looser-stability contract: diagnostic outputs are advisory and may change as the detector internals evolve, independently of the Detector::detect result contract.

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSend for T
where T: Any + Send,

§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Sync + Send>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

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

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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