@vitavision/overlays 0.2.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -35,7 +35,7 @@ A `TargetDetection` is one detection run, independent of the library that produc
35
35
  | Field | Items |
36
36
  |---|---|
37
37
  | `kind` | `"chessboard" \| "charuco" \| "markerboard" \| "puzzleboard" \| "ringgrid" \| "corners" \| "circles"`. The four boards draw lattice edges; the others do not. |
38
- | `corners` | `{ id, x, y, i?, j?, score?, angle?, angle2?, label? }` |
38
+ | `corners` | `{ id, x, y, i?, j?, score?, angle?, angle2?, cov?, label? }` |
39
39
  | `markers` | `{ id, corners: [x0, y0, … x3, y3], label? }` |
40
40
  | `circles` | `{ id, x, y, polarity: "white" \| "black", i?, j?, label? }` |
41
41
  | `rings` | `{ id, x, y, outer: { rx, ry, angle }, inner?, label? }` |
@@ -43,8 +43,42 @@ A `TargetDetection` is one detection run, independent of the library that produc
43
43
 
44
44
  Positions are image pixels with the **centre of pixel `i` at coordinate `i`**, which is what the WASM detectors report and what stage2d expects: do not add 0.5. Angles are radians, clockwise on screen. `rx`, `ry` and `radius` are image pixels, so they scale with the image. Ids must be unique within a detection; `selectedIds` and `hoveredId` apply to every part that has the id.
45
45
 
46
+ `cov` is the position covariance `[xx, xy, yy]` in image pixels squared, drawn on request as an uncertainty ellipse (below).
47
+
46
48
  `edgeBitsFromPuzzleboard(edges, corners, alignment)` builds `edgeBits` from a PuzzleBoard decode: it maps each observed edge through the alignment (modulo the 501 master period) to its two corners and places the dot at the midpoint, with a radius of a quarter of the edge.
47
49
 
50
+ ## From calib-targets
51
+
52
+ `fromCalibTargets` maps a result of the `@vitavision/calib-targets` detectors to a `TargetDetection`. Tag the result with the detector that produced it; TypeScript then checks the rest against that detector's shape:
53
+
54
+ ```ts
55
+ import { fromCalibTargets } from "@vitavision/overlays";
56
+
57
+ fromCalibTargets({ kind: "chessboard", detection: detect_chessboard(w, h, gray, chess, params) });
58
+ fromCalibTargets({ kind: "charuco", detection: detect_charuco(w, h, gray, null, params) });
59
+ fromCalibTargets({ kind: "corners", corners: detect_corners(w, h, gray, chess) });
60
+
61
+ // The marker-board circles and the PuzzleBoard edge bits come from a diagnose_* call:
62
+ // `diagnosis` is diagnose_puzzleboard's payload, as plain objects.
63
+ const { result, diagnostics } = diagnosis;
64
+ fromCalibTargets({ kind: "puzzleboard", detection: result, diagnostics });
65
+ ```
66
+
67
+ | `kind` | Corners | Also |
68
+ |---|---|---|
69
+ | `chessboard` | lattice, labelled `i,j` from the grid's `(u, v)` | |
70
+ | `charuco` | lattice | `markers` from each marker's `corners_img`, labelled with its dictionary id |
71
+ | `markerboard` | lattice | `circles` from `diagnostics`: the matched board circles, at the candidate's centre |
72
+ | `puzzleboard` | lattice in master indices | `edgeBits` from `diagnostics.observed_edges`, through the alignment |
73
+ | `puzzlepole` | drawn as a `puzzleboard` lattice | |
74
+ | `corners` | both axes as edge directions; `strength` is the score | |
75
+
76
+ - **Positions** pass through unchanged: calib-targets reports the centre of pixel `i` at `i`, as the overlay expects.
77
+ - **Ids** are `corner-<n>`, `marker-<n>` and `circle-<n>`, `n` being the index into the result's `corners`, `markers` or `circle_matches`, so a hover or press maps straight back to the item.
78
+ - **A miss** (`detection: null`, or `undefined` from a `diagnose_*` call) gives an empty detection of the same kind.
79
+ - **Covariance**: a corner's `position_covariance`, when the result has one, becomes its `cov`. Results without the field are accepted as they are.
80
+ - **No dependency**: the input types are the minimal structure the mapping reads, so the package does not depend on `@vitavision/calib-targets`; its result types fit them as they are. A `diagnose_*` payload must be plain objects: convert it first if it arrives as `Map`s.
81
+
48
82
  ## What is drawn
49
83
 
50
84
  Each part goes to the stage2d layer that fits it, batched by appearance, so a detection of thousands of items is a few dozen DOM nodes and the pointer is resolved by the stage's hit-test index.
@@ -56,11 +90,14 @@ Each part goes to the stage2d layer that fits it, batched by appearance, so a de
56
90
  | `circles` | white: a hollow ring; black: a ring with a centre dot | `PointSet` |
57
91
  | `rings` | the fitted outer and inner ellipse (exact arcs, image-sized) and a plus at the centre | `EllipseSet` + `PointSet` |
58
92
  | `edgeBits` | a dot on the edge: solid for 1, dashed for 0, opacity 35 to 100 % from confidence | `EllipseSet` |
93
+ | corners' `cov` | with `uncertainty={{ scale }}`: the 1σ ellipse, both semi-axes × `scale`, under the corners | `EllipseSet` |
59
94
 
60
95
  Colours are overlay roles only (`feature`, `model`, `structure`, `selection`). A score is never drawn as a verdict colour; polarity and bits are shapes, not hues.
61
96
 
62
97
  States follow the overlay grammar: hover 2 px, selected 2.5 px in the selection colour with a ring on points, dimmed at 35 % opacity (`dimmed` takes `true`, a list of ids, or a predicate). Labels appear only where items are 24 screen px apart, at most 200 at a time.
63
98
 
99
+ **Uncertainty ellipses** are opt-in: `uncertainty={{ scale: 40 }}`. A detector's σ is a small fraction of a pixel, so the ellipse is drawn magnified; its shape and orientation are the data's, and its size is σ × `scale`. Print the scale beside the image ("ellipses ×40"), as you would a residual's gain; the layer's accessible name carries it too. The ellipses are in the `model` role, follow their corner's hover, selection and dimming, and are not picked. A covariance that is not positive definite is not drawn.
100
+
64
101
  `onHoverChange` and `onItemPress` report `{ id, part }` with the id from the detection (`part` is `"corner"`, `"marker"`, `"circle"` or `"ring"`). A hover that moves between layers is reported once.
65
102
 
66
103
  ## Pieces
@@ -70,7 +107,7 @@ For an app that composes the layers itself:
70
107
  - **Lattice**: `cornerGrid`, `gridEdges`, `idByGrid`, `gridKey`, `markerPolygons` (pure; `gridEdges` is stage2d's `latticeEdges` with positions).
71
108
  - **Glyphs**: `TARGET_MARKERS` (`directed`, `circle-white`, `circle-black`) for `PointSet`'s `markers`; the `directed` marker reads a corner's two edge directions from `PointSetItem.angle` and `angle2`.
72
109
  - **Layers**: `EllipseSet` and `ellipsePath`, re-exported from `@vitavision/stage2d`: a batched set of ellipses whose size is data. `TargetOverlay` draws its rings with `pickable={false}`.
73
- - **Mapping**: `cornerNodes`, `markerAreas`, `circlePoints`, `ringCentres`, `ringEllipses`, `edgeBitEllipses` are the detection-to-layer-items functions `TargetOverlay` uses.
110
+ - **Mapping**: `cornerNodes`, `markerAreas`, `circlePoints`, `ringCentres`, `ringEllipses`, `edgeBitEllipses`, `uncertaintyEllipses` are the detection-to-layer-items functions `TargetOverlay` uses. `covarianceEllipse(cov, scale)` is the eigen-decomposition behind the last: the ellipse of a 2×2 covariance, or `null` when it is not positive definite.
74
111
 
75
112
  ## License
76
113
 
package/dist/index.d.ts CHANGED
@@ -5,8 +5,9 @@ import { AreaSetItem, EllipseSet, EllipseSetItem, EllipseSetItem as EllipseSetIt
5
5
  *
6
6
  * Every detector in the vitavision family (calib-targets' chessboard, ChArUco, marker board and
7
7
  * PuzzleBoard, ringgrid, chess-corners) returns its own result shape. An app maps that shape to a
8
- * `TargetDetection` once, and the overlay never learns which library ran. Nothing here imports a
9
- * detector package: these are plain data types.
8
+ * `TargetDetection` once (for calib-targets, `fromCalibTargets` is that mapping), and the overlay
9
+ * never learns which library ran. Nothing here imports a detector package: these are plain data
10
+ * types.
10
11
  *
11
12
  * Conventions, the same as `@vitavision/stage2d`:
12
13
  * - Positions are **image pixels, with the centre of pixel `i` at coordinate `i`** (the frame
@@ -50,8 +51,26 @@ interface TargetCorner {
50
51
  angle?: number | undefined;
51
52
  /** Orientation of the second edge through the corner, radians. Needs `angle`. */
52
53
  angle2?: number | undefined;
54
+ /**
55
+ * The covariance of the position, image pixels squared: the three distinct entries
56
+ * `[xx, xy, yy]` of the symmetric 2×2 matrix. `TargetOverlay`'s `uncertainty` prop draws it as
57
+ * a 1σ ellipse; a matrix that is not positive definite is not drawn.
58
+ */
59
+ cov?: readonly [xx: number, xy: number, yy: number] | undefined;
53
60
  /** Text beside it. Defaults to the lattice index `i,j` on a board, else the id. */
54
61
  label?: string | undefined;
62
+ /**
63
+ * The feature is excluded from use (left out of a fit, switched off by the person): it is
64
+ * drawn dimmed with a small cross through it. It is a state of the feature, not a verdict on
65
+ * it, so it is not drawn like a rejected point. It still takes hover and presses.
66
+ */
67
+ excluded?: boolean | undefined;
68
+ /**
69
+ * The feature is flagged: a thin ring is drawn around it, for "this feature disagrees with
70
+ * what it should be" (a decoded id that differs from the master pattern, say). It composes
71
+ * with `excluded`, hover and selection.
72
+ */
73
+ flagged?: boolean | undefined;
55
74
  }
56
75
  /** One decoded fiducial marker (ArUco, AprilTag): a quad. */
57
76
  interface TargetMarker {
@@ -83,6 +102,18 @@ interface TargetCircle {
83
102
  j?: number | undefined;
84
103
  /** Text beside it. Defaults to `(i, j)` when both are set. */
85
104
  label?: string | undefined;
105
+ /**
106
+ * The feature is excluded from use (left out of a fit, switched off by the person): it is
107
+ * drawn dimmed with a small cross through it. It is a state of the feature, not a verdict on
108
+ * it, so it is not drawn like a rejected point. It still takes hover and presses.
109
+ */
110
+ excluded?: boolean | undefined;
111
+ /**
112
+ * The feature is flagged: a thin ring is drawn around it, for "this feature disagrees with
113
+ * what it should be" (a decoded id that differs from the master pattern, say). It composes
114
+ * with `excluded`, hover and selection.
115
+ */
116
+ flagged?: boolean | undefined;
86
117
  }
87
118
  /** A fitted ellipse. */
88
119
  interface TargetEllipse {
@@ -107,6 +138,18 @@ interface TargetRing {
107
138
  inner?: TargetEllipse | undefined;
108
139
  /** Text beside the centre. Defaults to the id. */
109
140
  label?: string | undefined;
141
+ /**
142
+ * The ring is excluded from use (left out of a fit, switched off by the person): it is
143
+ * drawn dimmed with a small cross through it. It is a state of the feature, not a verdict on
144
+ * it, so it is not drawn like a rejected point. It still takes hover and presses.
145
+ */
146
+ excluded?: boolean | undefined;
147
+ /**
148
+ * The ring is flagged: a thin ring is drawn around its centre, for "this feature disagrees with
149
+ * what it should be" (a decoded id that differs from the master pattern, say). It composes
150
+ * with `excluded`, hover and selection.
151
+ */
152
+ flagged?: boolean | undefined;
110
153
  }
111
154
  /**
112
155
  * One decoded bit of a PuzzleBoard, drawn as a dot on the edge between two corners.
@@ -183,6 +226,19 @@ interface TargetOverlayProps {
183
226
  * opacity. They still take hover and presses. Pass a stable value: a new one re-batches.
184
227
  */
185
228
  dimmed?: boolean | Iterable<TargetId> | ((id: TargetId) => boolean) | undefined;
229
+ /**
230
+ * Draw each corner's position covariance (`cov`) as its 1σ ellipse with both semi-axes
231
+ * multiplied by `scale`, in the `model` role, under the corners. Off by default.
232
+ *
233
+ * A detector's σ is a small fraction of a pixel, so the ellipses are drawn magnified: the
234
+ * `scale` is the app's to choose and to print beside the image ("ellipses ×40"), as a
235
+ * residual's gain is. Their shape and orientation are the data's. A corner with no covariance,
236
+ * or one that is not positive definite, gets none. The ellipses take the corner's hover,
237
+ * selection and dimming, and are not picked themselves.
238
+ */
239
+ uncertainty?: {
240
+ scale: number;
241
+ } | undefined;
186
242
  /** Prefix of the hit-test layer ids (`<prefix>-corners`, `-markers`, `-circles`, `-rings`). Defaults to generated ids. */
187
243
  layerIdPrefix?: string | undefined;
188
244
  }
@@ -198,10 +254,16 @@ interface TargetOverlayProps {
198
254
  * - **Callbacks** report `{ id, part }` with the id from the detection. A press and a hover move
199
255
  * between layers (a corner, then the marker under it) without a flicker: the change is reported
200
256
  * once.
257
+ * - **Excluded and flagged features**: a corner, circle or ring with `excluded` is drawn dimmed
258
+ * with a small cross through it (a state, not a rejection); one with `flagged` has a thin ring
259
+ * around it (a mismatch with the master pattern, say). Both are drawn in the `label` role on a
260
+ * halo, compose with hover, selection and each other, and are not picked themselves.
261
+ * - **Uncertainty** (opt-in, `uncertainty`): each corner's covariance as a 1σ ellipse × the
262
+ * given scale, under the corners.
201
263
  *
202
264
  * The layers it renders carry their own accessible names ("Corners: 54 points, 0 selected").
203
265
  */
204
- export declare function TargetOverlay({ detection, showEdges, showLabels, hoveredId, selectedIds, onHoverChange, onItemPress, dimmed, layerIdPrefix }: TargetOverlayProps): import("react").JSX.Element;
266
+ export declare function TargetOverlay({ detection, showEdges, showLabels, hoveredId, selectedIds, onHoverChange, onItemPress, dimmed, uncertainty, layerIdPrefix }: TargetOverlayProps): import("react").JSX.Element;
205
267
  //#endregion
206
268
  //#region src/lattice.d.ts
207
269
  /** A corner that has a place on the board. */
@@ -359,6 +421,10 @@ export declare const TARGET_MARKERS: {
359
421
  readonly "circle-white": MarkerShape;
360
422
  /** A black matched circle. */
361
423
  readonly "circle-black": MarkerShape;
424
+ /** The cross through an excluded feature. */
425
+ readonly excluded: MarkerShape;
426
+ /** The ring around a flagged feature. */
427
+ readonly flagged: MarkerShape;
362
428
  };
363
429
  //#endregion
364
430
  //#region src/layerItems.d.ts
@@ -416,6 +482,249 @@ export declare function ringEllipses(rings: readonly TargetRing[]): {
416
482
  * @returns One ellipse (a circle) per bit.
417
483
  */
418
484
  export declare function edgeBitEllipses(bits: readonly TargetEdgeBit[]): EllipseSetItem$1[];
485
+ /**
486
+ * The ellipse of a 2×2 position covariance: `scale` standard deviations along each principal
487
+ * axis.
488
+ *
489
+ * The semi-axes are `scale · √λ` for the matrix's two eigenvalues `λ₁ ≥ λ₂`, and `angle` is the
490
+ * direction of the eigenvector of `λ₁` (radians, clockwise on screen, in `(-π/2, π/2]`). At
491
+ * `scale = 1` this is the 1σ ellipse: the curve `dᵀ Σ⁻¹ d = 1`.
492
+ *
493
+ * @param cov - The covariance `[xx, xy, yy]`, image pixels squared.
494
+ * @param scale - The gain applied to both semi-axes. Defaults to 1.
495
+ * @returns The ellipse, or `null` when the matrix is not finite and positive definite, or the
496
+ * scale is not a finite positive number: there is no ellipse to draw.
497
+ */
498
+ export declare function covarianceEllipse(cov: readonly [xx: number, xy: number, yy: number], scale?: number): TargetEllipse | null;
499
+ /**
500
+ * The ellipses of the uncertainty layer: each corner's position covariance as a 1σ ellipse,
501
+ * both semi-axes multiplied by `scale`, centred on the corner and sharing its id, in the `model`
502
+ * role. A corner with no covariance, or one that is not positive definite, has none.
503
+ *
504
+ * @param corners - The corners.
505
+ * @param scale - The gain on the semi-axes. A detector's σ is a fraction of a pixel, so it is
506
+ * drawn magnified; print the gain beside the image ("ellipses ×40").
507
+ * @returns One ellipse per corner with a drawable covariance, in order.
508
+ */
509
+ export declare function uncertaintyEllipses(corners: readonly TargetCorner[], scale: number): EllipseSetItem$1[];
510
+ /**
511
+ * The strike-through points of the excluded features: a corner, circle or ring with
512
+ * `excluded` set gets one `excluded` glyph at its position. Markers carry no flags.
513
+ *
514
+ * @param detection - The detection.
515
+ * @returns One point per excluded feature, corners first, then circles, then rings.
516
+ */
517
+ export declare function excludedPoints(detection: TargetDetection): PointSetItem[];
518
+ /**
519
+ * The ring points of the flagged features: a corner, circle or ring with `flagged` set gets one
520
+ * `flagged` glyph at its position.
521
+ *
522
+ * @param detection - The detection.
523
+ * @returns One point per flagged feature, corners first, then circles, then rings.
524
+ */
525
+ export declare function flaggedPoints(detection: TargetDetection): PointSetItem[];
526
+ //#endregion
527
+ //#region src/calibTargets.d.ts
528
+ /** An image point `[x, y]`, pixels with the centre of pixel `i` at `i` (calib-targets' `Point2`). */
529
+ type CalibTargetsPoint = readonly [x: number, y: number];
530
+ /** A position covariance, image pixels squared (calib-targets' `position_covariance`). */
531
+ interface CalibTargetsCovariance {
532
+ /** Variance along x. */
533
+ xx: number;
534
+ /** Covariance of x and y. */
535
+ xy: number;
536
+ /** Variance along y. */
537
+ yy: number;
538
+ }
539
+ /** An integer lattice coordinate (calib-targets' `Coord`): `u` along the first board axis, `v` the second. */
540
+ interface CalibTargetsCoord {
541
+ /** First axis, rightwards on the board. */
542
+ u: number;
543
+ /** Second axis, downwards on the board. */
544
+ v: number;
545
+ }
546
+ /** A labelled board corner: what `ChessboardCorner`, `CharucoCorner`, `MarkerBoardCorner` and `PuzzleBoardCorner` share. */
547
+ interface CalibTargetsLabeledCorner {
548
+ /** Sub-pixel image position. */
549
+ position: CalibTargetsPoint;
550
+ /** Lattice label; `null` for a corner with no place on the board. */
551
+ grid: CalibTargetsCoord | null;
552
+ /** The detector's score, higher is better. */
553
+ score: number;
554
+ /** Position covariance, when the detector reports one. */
555
+ position_covariance?: CalibTargetsCovariance | null | undefined;
556
+ }
557
+ /** One axis estimate of a raw corner (calib-targets' `AxisEstimate`). */
558
+ interface CalibTargetsAxis {
559
+ /** Direction of the axis, radians in the image frame (clockwise on screen). */
560
+ angle: number;
561
+ }
562
+ /** A raw ChESS corner, as `detect_corners` returns it (calib-targets' `Corner`). */
563
+ interface CalibTargetsCorner {
564
+ /** Sub-pixel image position. */
565
+ position: CalibTargetsPoint;
566
+ /** The two grid axes through the corner. */
567
+ axes: readonly [CalibTargetsAxis, CalibTargetsAxis];
568
+ /** Corner response, higher is stronger. */
569
+ strength: number;
570
+ /** Position covariance, when the detector reports one. */
571
+ position_covariance?: CalibTargetsCovariance | null | undefined;
572
+ }
573
+ /** A chessboard detection (`ChessboardDetection`). */
574
+ interface CalibTargetsChessboardDetection {
575
+ /** The labelled corners. */
576
+ corners: readonly CalibTargetsLabeledCorner[];
577
+ }
578
+ /** A decoded ArUco marker of a ChArUco detection (`MarkerDetection`). */
579
+ interface CalibTargetsMarker {
580
+ /** The marker's dictionary id. */
581
+ id: number;
582
+ /** Its four corners in the image, in the marker's own order; `null` when they were not projected. */
583
+ corners_img: readonly [CalibTargetsPoint, CalibTargetsPoint, CalibTargetsPoint, CalibTargetsPoint] | null;
584
+ }
585
+ /** A ChArUco detection (`CharucoDetection`). */
586
+ interface CalibTargetsCharucoDetection {
587
+ /** The labelled corners. */
588
+ corners: readonly CalibTargetsLabeledCorner[];
589
+ /** The markers consistent with the board alignment. */
590
+ markers: readonly CalibTargetsMarker[];
591
+ }
592
+ /** A checkerboard marker board detection (`MarkerBoardDetection`). */
593
+ interface CalibTargetsMarkerBoardDetection {
594
+ /** The labelled corners. */
595
+ corners: readonly CalibTargetsLabeledCorner[];
596
+ }
597
+ /** A scored circle hypothesis of a marker board (`CircleCandidate`). */
598
+ interface CalibTargetsCircleCandidate {
599
+ /** Centre of the circle in the image. */
600
+ center_img: CalibTargetsPoint;
601
+ }
602
+ /** A board circle paired with a detected one (`CircleMatch`). */
603
+ interface CalibTargetsCircleMatch {
604
+ /** The circle the board layout expects: its cell and printed polarity. */
605
+ expected: {
606
+ cell: {
607
+ i: number;
608
+ j: number;
609
+ };
610
+ polarity: "white" | "black";
611
+ };
612
+ /** Index into `circle_candidates` of the circle that matched it, or `null` for none. */
613
+ matched_index: number | null;
614
+ }
615
+ /** The part of `diagnose_marker_board`'s `diagnostics` the overlay draws (`MarkerBoardDiagnostics`). */
616
+ interface CalibTargetsMarkerBoardDiagnostics {
617
+ /** The circle hypotheses. */
618
+ circle_candidates: readonly CalibTargetsCircleCandidate[];
619
+ /** The board's circles and the candidates they matched. */
620
+ circle_matches: readonly CalibTargetsCircleMatch[];
621
+ }
622
+ /** A grid alignment (`GridAlignment`): `master = matrix · local + translation`. */
623
+ interface CalibTargetsAlignment {
624
+ /** Row-major integer matrix, applied to local `(u, v)` before the translation. */
625
+ matrix: readonly [readonly [number, number], readonly [number, number]];
626
+ /** Integer translation, grid units. */
627
+ translation: readonly [number, number];
628
+ }
629
+ /** A PuzzleBoard detection (`PuzzleBoardDetection`); its corners carry master labels. */
630
+ interface CalibTargetsPuzzleBoardDetection {
631
+ /** The labelled corners, `grid` in the master frame. */
632
+ corners: readonly CalibTargetsLabeledCorner[];
633
+ /** The map from the decoder's local frame to the master frame. */
634
+ alignment: CalibTargetsAlignment;
635
+ }
636
+ /** One observed edge bit, in the decoder's local frame (`PuzzleBoardObservedEdge`). */
637
+ interface CalibTargetsObservedEdge {
638
+ /** Row of the edge's first corner. */
639
+ row: number;
640
+ /** Column of the edge's first corner. */
641
+ col: number;
642
+ /** Which neighbour the edge runs to. */
643
+ orientation: "horizontal" | "vertical";
644
+ /** The observed bit, 0 or 1. */
645
+ bit: number;
646
+ /** Per-bit confidence, [0, 1]. */
647
+ confidence: number;
648
+ }
649
+ /** The part of `diagnose_puzzleboard`'s `diagnostics` the overlay draws (`PuzzleBoardDiagnostics`). */
650
+ interface CalibTargetsPuzzleBoardDiagnostics {
651
+ /** Every sampled edge, before alignment. */
652
+ observed_edges: readonly CalibTargetsObservedEdge[];
653
+ }
654
+ /** A PuzzlePole detection: a PuzzleBoard wrapped round a cylinder; `grid` is (axial, around). */
655
+ interface CalibTargetsPuzzlePoleDetection {
656
+ /** The labelled corners. */
657
+ corners: readonly CalibTargetsLabeledCorner[];
658
+ }
659
+ /**
660
+ * One calib-targets result, tagged with the detector that produced it.
661
+ *
662
+ * A board detector returns `null` (or, from `diagnose_*`, `undefined`) when it finds nothing;
663
+ * pass that through as `detection` and the result is an empty detection of the same kind.
664
+ * `diagnostics` is the `diagnostics` of the matching `diagnose_*` call: it carries what the plain
665
+ * result does not (the marker-board circles, the PuzzleBoard edge bits). Convert a `diagnose_*`
666
+ * payload to plain objects first if your binding returns `Map`s.
667
+ */
668
+ type CalibTargetsResult = {
669
+ /** Raw ChESS corners, from `detect_corners`. */
670
+ kind: "corners";
671
+ /** The corners. */
672
+ corners: readonly CalibTargetsCorner[];
673
+ } | {
674
+ /** A chessboard, from `detect_chessboard`. */
675
+ kind: "chessboard";
676
+ /** The detection, or `null` when none was found. */
677
+ detection: CalibTargetsChessboardDetection | null | undefined;
678
+ } | {
679
+ /** A ChArUco board, from `detect_charuco` or `diagnose_charuco`. */
680
+ kind: "charuco";
681
+ /** The detection, or `null` when none was found. */
682
+ detection: CalibTargetsCharucoDetection | null | undefined;
683
+ } | {
684
+ /** A checkerboard marker board, from `detect_marker_board` or `diagnose_marker_board`. */
685
+ kind: "markerboard";
686
+ /** The detection, or `null` when none was found. */
687
+ detection: CalibTargetsMarkerBoardDetection | null | undefined;
688
+ /** `diagnose_marker_board`'s diagnostics, for the matched circles. */
689
+ diagnostics?: CalibTargetsMarkerBoardDiagnostics | null | undefined;
690
+ } | {
691
+ /** A PuzzleBoard, from `detect_puzzleboard` or `diagnose_puzzleboard`. */
692
+ kind: "puzzleboard";
693
+ /** The detection, or `null` when none was found. */
694
+ detection: CalibTargetsPuzzleBoardDetection | null | undefined;
695
+ /** `diagnose_puzzleboard`'s diagnostics, for the edge bits. */
696
+ diagnostics?: CalibTargetsPuzzleBoardDiagnostics | null | undefined;
697
+ } | {
698
+ /** A PuzzlePole. Drawn as a PuzzleBoard lattice, without edge bits. */
699
+ kind: "puzzlepole";
700
+ /** The detection, or `null` when none was found. */
701
+ detection: CalibTargetsPuzzlePoleDetection | null | undefined;
702
+ };
703
+ /**
704
+ * The `TargetDetection` of a calib-targets result.
705
+ *
706
+ * - **Kinds.** `chessboard`, `charuco`, `markerboard`, `puzzleboard` and raw `corners` map to the
707
+ * overlay kind of the same name; a `puzzlepole` is drawn as a `puzzleboard` lattice.
708
+ * - **Corners.** Positions pass through unchanged (calib-targets reports the centre of pixel `i`
709
+ * at `i`, as the overlay expects). A labelled corner's grid `(u, v)` becomes `(i, j)`, so a
710
+ * board draws its lattice and labels corners `i,j`. A raw corner draws its two axes (`angle`,
711
+ * `angle2`) and is labelled with its index; its `strength` is the `score`.
712
+ * - **Covariance.** A corner's `position_covariance`, when present and finite, becomes `cov`;
713
+ * `TargetOverlay` draws it with `uncertainty`.
714
+ * - **Markers** (ChArUco) are the quads of `corners_img`, labelled with the dictionary id; a
715
+ * marker without a projected quad is left out.
716
+ * - **Circles** (marker board, from `diagnostics`) are the board circles a candidate matched,
717
+ * at the candidate's centre with the board's cell and polarity.
718
+ * - **Edge bits** (PuzzleBoard, from `diagnostics`) are the observed edges placed through the
719
+ * alignment with `edgeBitsFromPuzzleboard`.
720
+ *
721
+ * Ids are `corner-<n>`, `marker-<n>` and `circle-<n>`, where `n` is the index into the result's
722
+ * `corners`, `markers` or `circle_matches`, so a hover or a press maps straight back to it.
723
+ *
724
+ * @param result - The result, tagged with its kind.
725
+ * @returns The detection for `TargetOverlay`. Parts with no items are left out.
726
+ */
727
+ export declare function fromCalibTargets(result: CalibTargetsResult): TargetDetection;
419
728
  //#endregion
420
- export { type CirclePolarity, type CornerGrid, EllipseSet, type EllipseSetItem, type EllipseSetProps, type GridBounds, type GridCorner, type GridSegment, type MarkerPolygon, type PuzzleboardAlignment, type PuzzleboardEdge, type TargetCircle, type TargetCorner, type TargetDetection, type TargetEdgeBit, type TargetEllipse, type TargetHit, type TargetId, type TargetKind, type TargetMarker, type TargetOverlayProps, type TargetPart, type TargetRing, ellipsePath };
729
+ export { type CalibTargetsAlignment, type CalibTargetsAxis, type CalibTargetsCharucoDetection, type CalibTargetsChessboardDetection, type CalibTargetsCircleCandidate, type CalibTargetsCircleMatch, type CalibTargetsCoord, type CalibTargetsCorner, type CalibTargetsCovariance, type CalibTargetsLabeledCorner, type CalibTargetsMarker, type CalibTargetsMarkerBoardDetection, type CalibTargetsMarkerBoardDiagnostics, type CalibTargetsObservedEdge, type CalibTargetsPoint, type CalibTargetsPuzzleBoardDetection, type CalibTargetsPuzzleBoardDiagnostics, type CalibTargetsPuzzlePoleDetection, type CalibTargetsResult, type CirclePolarity, type CornerGrid, EllipseSet, type EllipseSetItem, type EllipseSetProps, type GridBounds, type GridCorner, type GridSegment, type MarkerPolygon, type PuzzleboardAlignment, type PuzzleboardEdge, type TargetCircle, type TargetCorner, type TargetDetection, type TargetEdgeBit, type TargetEllipse, type TargetHit, type TargetId, type TargetKind, type TargetMarker, type TargetOverlayProps, type TargetPart, type TargetRing, ellipsePath };
421
730
  //# sourceMappingURL=index.d.ts.map