Skip to main content

extract_board

Function extract_board 

Source
pub fn extract_board(
    quads: &[LinkedQuad],
    coords: &HashMap<usize, QuadGrid>,
    pattern_w: usize,
    pattern_h: usize,
) -> Option<Vec<(f32, f32)>>
Expand description

Validate and extract a pattern_w x pattern_h board from a lattice-assigned connected component.

The reliable inner corners (referenced by >= 2 quads) must span a pattern_w x pattern_h lattice rectangle. Interior corners missing from that rectangle (because a neighboring square was not detected) are filled in — analogous to OpenCV’s board augmentation: a corner referenced by a single quad is taken directly, otherwise its position is predicted from a homography fit to the reliable corners (lattice -> pixel). The caller’s sub-pixel refinement then snaps any predicted corner to the true saddle.

Returns the corners row-major (lattice row then column), after a monotonicity check.