Plain / Rect Target Detection
Plain (uncoded) rings carry no per-marker identity, so the coded path’s decode → ID-correction → global-filter cannot label them. Instead, plain targets are labeled by their lattice position and, when the target carries origin fiducials, anchored to an absolute board frame. This page describes that path end to end.
The plain path shares the front half of the pipeline — proposal, outer estimate, outer fit, inner estimate, dedup, and projective center — with the coded path. It diverges in finalize: where the coded path decodes IDs, the plain path assigns grid coordinates. Which lattice × coding combination runs which path is summarized in the target composition matrix.
Finalize stages (plain path)
Orchestrated by pipeline/finalize/grid.rs (the back half every target runs; coded
targets anchor by decoded IDs instead of dots) when advanced.use_global_filter is true
(otherwise the shared no-homography passthrough runs and markers stay unlabeled):
| Order | Stage | Description |
|---|---|---|
| 1 | Projective center | Correct fit centers once per marker (shared with coded) |
| 2 | Grid assignment | Label ring centers with lattice coordinates; fit the frame homography |
| 3 | Origin anchor | Resolve the board origin from fiducial dots (when present) |
| 4 | Completion | Coordinate-keyed fits at missing cells; grows the labeled patch when unanchored, then retries the origin anchor |
| 5 | Final H refit | Refit the frame/board homography over all labeled markers |
| 6 | Geometric verify | The same lattice-consistency gate as the coded path |
Grid assignment
pipeline/assign.rs (assign_plain_grid) turns the finite ring centers into
lattice-labeled correspondences:
- Collect finite ring centers as point features (needs ≥ 4).
- Build a
projective_grid::detect_gridrequest carrying the lattice kind and, for rect, the(cols, rows)grid dimensions. - Call
detect_gridfor topological labeling only (its facade isf32). - Canonicalize the labels with
canonicalize_entries(both lattices) so a given physical layout always yields the same coordinate assignment.detect_gridlabels are defined only up to the lattice’s full symmetry group — reflections included (hex labels come out mirrored) — so canonicalization picks, from the whole dihedral group, the transform that makes the labeling orientation-preserving (the image-frame cross product of the+uand+vsteps has the sign of the lattice model basis, i.e. the labels relate to the board by a rotation + translation, never a reflection) and, among those, best aligns+uwith image+xand+vwith image+y. When no symmetry yields both a+uand a+vneighbor pair (e.g. a patch of two non-adjacent rows) the handedness cannot be measured and the labels are left asdetect_gridproduced them — possibly mirrored; origin resolution below still recovers the correct handedness in that case. - Refit the frame homography in
f64with ringgrid’sfit_homography_ransacover the labeled correspondences, keeping only homography inliers — mirroring the coded global filter.
The result is a set of markers labeled in a canonical relative frame. If
fewer than four centers survive, grid assignment returns None and the markers
pass through unlabeled.
Origin resolution
When the target carries origin fiducials and at
least four markers are labeled, pipeline/anchor.rs (resolve_origin) upgrades
the relative labeling to an absolute board frame:
- Fit the patch homography once. A DLT from relative-frame lattice millimetres to image pixels over every labeled ring. A placement only re-expresses board millimetres by a lattice isometry, under which the normalized DLT is equivariant, so one fit serves every placement.
- Enumerate placements by anchor cell. The dot triad surrounds board cell
(0, 0), so a placement is a lattice symmetry plus the relative-frame cell that carries the triad. That anchor cell is searched over the labeled patch’s coordinate bounds expanded by one lattice step, over the lattice’s full dihedral group (rotations and reflections): the count is set by the patch, not by the board, so a small window of a large board costs the same as a small board. A placement must put every labeled ring on a board cell. - Gate on orientation. A placement’s board→image map is the patch homography composed with the placement, so it is orientation-reversing exactly when its symmetry’s handedness differs from the patch homography’s. This physical check is what excludes reflections: when the relative frame is orientation-preserving (the normal case) every reflected placement fails it, and when canonicalization could not fix the handedness the reflected placements are the ones that pass.
- Score by dot darkness. Project each fiducial dot through the patch
homography and measure normalized
(background − dot)contrast with a distortion-aware disk-vs-annulus sample. A placement’s score is its weakest dot (the min over dots); a placement with a dot off-image is unscorable, not dark. - Accept the winner only if its contrast ≥
MIN_DOT_CONTRAST = 0.10and its margin over every other valid placement ≥MIN_MARGIN = 0.05. This “verify at predicted positions” test is deliberately conservative: a wrong origin is worse than an unresolved one. A dark speck that forms a second triad with two of the dots makes the view ambiguous (unresolved); a speck anywhere else cannot complete a triad.
Dots are verified only next to labeled rings, where the patch homography is measured. The labeler returns one connected component, which can stop short of the dots; an unresolved plain view therefore anchors once more after completion has grown the patch over the visible board.
On success, each marker’s grid_coord is remapped through the winning
coordinate map to absolute board cells, board_xy_mm is filled from the target’s
cell_xy_mm, and the working homography becomes the anchored board→image
homography.
Completion
Plain completion (complete_plain_with_h) is coordinate-keyed and
lattice-generic. It fits conservative markers at cells that the topological
labeler missed:
- Anchored: complete across the whole board.
- Unanchored: grow the labeled patch’s bounding box by one lattice ring per
round, recovering the neighbors
detect_griddropped without assuming a board extent.
New completion markers receive their own projective-center correction.
Frame contract
enforce_plain_frame_contract makes the output frame explicit and honest
(pipeline/result.rs, BoardFrame):
- Anchored → [
BoardFrame::Absolute]:grid_coordis in board cells andboard_xy_mmis populated. - Unanchored → [
BoardFrame::RelativeCanonical]:grid_coordis in the canonical relative frame and allboard_xy_mmare cleared toNone— a wrong millimeter position is worse than none.
Coded targets always report board_frame = absolute (IDs are globally unique);
the relative/absolute distinction only arises for plain targets.
Source: pipeline/finalize/grid.rs, pipeline/finalize/mod.rs,
pipeline/assign.rs, pipeline/anchor.rs, pipeline/result.rs,
target/fiducials.rs