Skip to main content

detect_grid

Function detect_grid 

Source
pub fn detect_grid(
    request: DetectionRequest<'_>,
) -> Result<GridDetection, GridError>
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
(Hex, Oriented3)supported — topological only
(Hex, Positions)supported — synthesize 3 axes, then hex topological
(Hex, Oriented1)supported — keep trusted family, synthesize 2 axes
(Hex, Oriented2)UnsupportedCombination
  • (Square, Oriented2) — the axis-driven SBF09 topological grid finder (Delaunay → quad-mesh → flood-fill → validate → fit) returns a labelled GridDetection 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::expert::orientation::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::expert::orientation::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.
  • (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::expert::orientation::synthesize_oriented3) and then fed to the hex topological path, mirroring the (Square, Positions) seam.
  • (Hex, Oriented1) — one measured axis representing the same physical hex family at every feature. The measured observation is preserved and the two missing local directions are inferred from neighbour geometry.

(Square, Oriented3) (square does not consume triple-axis evidence) and (Hex, Oriented2) (no unambiguous physical-family contract) 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.