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
impl Detector
Sourcepub fn new(cfg: DetectorConfig) -> Result<Self, ChessError>
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.
Sourcepub fn with_default() -> Self
pub fn with_default() -> Self
Build a detector with the default config.
Sourcepub fn config(&self) -> &DetectorConfig
pub fn config(&self) -> &DetectorConfig
Borrow the active config.
Sourcepub fn set_config(&mut self, cfg: DetectorConfig) -> Result<(), ChessError>
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.
Sourcepub fn detect_u8(
&mut self,
img: &[u8],
width: u32,
height: u32,
) -> Result<Vec<CornerDescriptor>, ChessError>
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).
Sourcepub fn detect(
&mut self,
img: &GrayImage,
) -> Result<Vec<CornerDescriptor>, ChessError>
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.
Sourcepub fn detect_u8_roi(
&mut self,
img: &[u8],
width: u32,
height: u32,
roi: Roi,
) -> Result<Vec<CornerDescriptor>, ChessError>
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.
Sourcepub fn detect_roi(
&mut self,
img: &GrayImage,
roi: Roi,
) -> Result<Vec<CornerDescriptor>, ChessError>
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.
Sourcepub fn diagnostics(&self) -> DetectorDiagnostics<'_>
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§
impl !RefUnwindSafe for Detector
impl !UnwindSafe for Detector
impl Freeze for Detector
impl Send for Detector
impl Sync for Detector
impl Unpin for Detector
impl UnsafeUnpin for Detector
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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