Skip to main content

detect_grid

Function detect_grid 

Source
pub fn detect_grid(request: DetectionRequest<'_>) -> Result<GridSolution>
Expand description

Detect a grid from feature evidence.

§Support matrix

(lattice, evidence)Status
(Square, Oriented2)supported — topological assembler
(Square, Oriented1)supported — synthesize 2nd axis, then Oriented2
(Square, Positions)supported — synthesize both axes, then Oriented2
(Square, Oriented3)UnsupportedCombination
(Square, CoordinateHypotheses)UnsupportedCombination (roadmap)
(Hex, Oriented3)supported — topological only
(Hex, Positions)supported — synthesize 3 axes, then hex topological
(Hex, Oriented1 / Oriented2)UnsupportedCombination
  • (Square, Oriented2) — the axis-driven SBF09 topological grid finder (Delaunay → quad-mesh → flood-fill → validate → fit) returns a labelled GridSolution with a fitted projective transform; downstream consumers stay agnostic.

  • (Square, Positions) — orientation-free input. Each corner’s two local grid directions are synthesized from neighbour geometry (crate::orient::synthesize_oriented2) and then fed to the topological assembler, exactly as for (Square, Oriented2) — with the geometry-only RecoverySchedule enabled to recover the synthesized-axis recall. Use this for dot / circle grids and for chessboards whose corners carry no axis estimate.

  • (Square, Oriented1) — single-axis input. The supplied axis is kept and the orthogonal grid direction is recovered from neighbour geometry (crate::orient::synthesize_oriented2_from_oriented1); the resulting OrientedFeature<2> then runs the topological assembler, exactly as for (Square, Positions). Use this for detectors that recover one dominant edge orientation per feature but not the orthogonal one.

  • Every other combination — typed GridError::UnsupportedCombination.

  • (Hex, Oriented3) — hex-native triple-axis evidence. Runs the hex topological grid finder (Delaunay triangles are the unit cells; no diagonal class, no triangle-pair merge; axial (q, r) flood-fill walk). Hex is topological-only with no recovery schedule.

  • (Hex, Positions) — orientation-free hex input. The three local grid directions are synthesized from neighbour geometry (crate::orient::synthesize_oriented3) and then fed to the hex topological path, mirroring the (Square, Positions) seam.

(Square, Oriented3) (square does not consume triple-axis evidence), (Square, CoordinateHypotheses) (a decode-feedback roadmap slot), and (Hex, Oriented1) / (Hex, Oriented2) (hex needs three axis families) stay UnsupportedCombination — no working algorithm exists for those slots.

Multi-component results. The topological assembler can produce more than one connected component (it labels each connected quad-mesh component, then runs local component merge). This entry point returns the largest component only. Use detect_grid_all when secondary components must be preserved with their own (u, v) labels.