@vitavision/overlays 0.1.0 → 0.1.1
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/dist/index.d.ts +512 -0
- package/dist/index.js +870 -0
- package/dist/index.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/glyphs.ts","../src/EllipseSet.tsx","../src/lattice.ts","../src/model.ts","../src/layerItems.ts","../src/TargetOverlay.tsx","../src/puzzleboard.ts"],"sourcesContent":["/**\n * The glyphs of a calibration-target overlay, as path generators.\n *\n * A glyph is a `MarkerShape` for `@vitavision/stage2d`'s `PointSet`: a pure function from a\n * position to SVG path data, so a layer appends thousands of them into one `<path>` (ADR-0004).\n * They are registered under the names in `TARGET_MARKERS`, which `TargetOverlay` passes as\n * `markers`. Sizes are screen pixels, from `unit` (image pixels per screen pixel).\n *\n * `MarkerShape.path` receives one number per item, `angle`. A corner with two edge directions\n * needs two, so `packAxes` folds both into that one number (see below); that is the only reason\n * the packing exists.\n *\n * Pure: no React, no DOM.\n */\n\nimport { circlePath, type MarkerShape } from \"@vitavision/stage2d\";\n\n/** Round to 1/1000 of an image pixel. */\nfunction round(value: number): number {\n return Math.round(value * 1000) / 1000;\n}\n\n/** Quantisation steps per half turn when two axes share one number: 2²⁶, so about 4.7e-8 rad. */\nconst STEPS = 2 ** 26;\n/** Packed values start here; a plain angle (normalised to [0, π)) is always below it. */\nconst PACKED_FLOOR = 8;\n\n/** An angle as a direction of a line: modulo π, in [0, π). */\nfunction lineAngle(angle: number): number {\n const wrapped = angle % Math.PI;\n return wrapped < 0 ? wrapped + Math.PI : wrapped;\n}\n\n/**\n * Fold one or two edge directions into the single `angle` number a `MarkerShape` receives.\n *\n * Directions are lines (`θ` and `θ + π` are the same line), so each is taken modulo π. With one\n * direction the result is that angle in [0, π). With two they are quantised to 2⁻²⁶ of a half\n * turn (4.7e-8 rad, under a millionth of a screen pixel on a 10 px glyph) and packed into one\n * integer-valued double above 8, which stays exact because it is below 2⁵³. `unpackAxes` is the\n * inverse.\n *\n * @param angle - The first direction, radians.\n * @param angle2 - The second direction, radians. Optional.\n * @returns A number to put in `PointSetItem.angle` for the `directed` marker.\n */\nexport function packAxes(angle: number, angle2?: number): number {\n if (angle2 === undefined) return lineAngle(angle);\n const q = (a: number) => Math.round((lineAngle(a) / Math.PI) * STEPS) % STEPS;\n return PACKED_FLOOR + q(angle) * STEPS + q(angle2);\n}\n\n/**\n * The directions folded into `angle` by `packAxes`.\n *\n * @param packed - A value from `packAxes`, or a plain angle in radians.\n * @returns One direction for a plain angle, two for a packed value; each in [0, π).\n */\nexport function unpackAxes(packed: number): number[] {\n if (!Number.isFinite(packed)) return [];\n if (packed < PACKED_FLOOR) return [lineAngle(packed)];\n const rest = packed - PACKED_FLOOR;\n const first = Math.floor(rest / STEPS);\n return [(first / STEPS) * Math.PI, ((rest - first * STEPS) / STEPS) * Math.PI];\n}\n\n/** Half-length of a directed corner's axes, and the gap left at its centre, in screen pixels. */\nconst AXIS_REACH = 8;\nconst AXIS_GAP = 2;\n\n/**\n * A corner with its edge directions: one or two lines through the point, 8 px each way with a\n * 2 px gap at the centre, so the corner itself stays visible. Give it `angle: packAxes(a, b)`.\n */\nconst directed: MarkerShape = {\n paint: \"line\",\n size: AXIS_REACH,\n path: (x, y, unit, packed) => {\n let d = \"\";\n for (const angle of unpackAxes(packed)) {\n const c = Math.cos(angle);\n const s = Math.sin(angle);\n const near = AXIS_GAP * unit;\n const far = AXIS_REACH * unit;\n d +=\n `M${round(x - far * c)} ${round(y - far * s)}L${round(x - near * c)} ${round(y - near * s)}` +\n `M${round(x + near * c)} ${round(y + near * s)}L${round(x + far * c)} ${round(y + far * s)}`;\n }\n return d;\n },\n};\n\n/** Radius of a matched circle's glyph, screen pixels. */\nconst CIRCLE_RADIUS = 5.5;\n/** Radius of the centre mark of a black circle, screen pixels; stroked, it reads as a filled dot. */\nconst CENTRE_RADIUS = 0.8;\n\n/** A white circle of a marker board: a hollow ring of radius 5.5 px. */\nconst circleWhite: MarkerShape = {\n paint: \"line\",\n size: CIRCLE_RADIUS,\n path: (x, y, unit) => circlePath(x, y, CIRCLE_RADIUS * unit),\n};\n\n/** A black circle: the same ring with a dot at its centre, so polarity is a shape and not a colour. */\nconst circleBlack: MarkerShape = {\n paint: \"line\",\n size: CIRCLE_RADIUS,\n path: (x, y, unit) => circlePath(x, y, CIRCLE_RADIUS * unit) + circlePath(x, y, CENTRE_RADIUS * unit),\n};\n\n/** The marker names `TargetOverlay` uses, to pass to `PointSet`'s `markers`. */\nexport const TARGET_MARKERS = {\n /** Edge directions of a corner; see `packAxes`. */\n directed,\n /** A white matched circle. */\n \"circle-white\": circleWhite,\n /** A black matched circle. */\n \"circle-black\": circleBlack,\n} as const satisfies Readonly<Record<string, MarkerShape>>;\n\n/**\n * An ellipse as two arcs, exactly: no polygon approximation, so it stays round at any zoom.\n *\n * @param cx - Centre x, image pixels.\n * @param cy - Centre y, image pixels.\n * @param rx - Semi-axis along the rotated x axis, image pixels.\n * @param ry - Semi-axis along the rotated y axis, image pixels.\n * @param angle - Rotation of the `rx` axis, radians clockwise on screen.\n * @returns Path data, or `\"\"` for a degenerate ellipse (a non-finite value, or a radius not above zero).\n */\nexport function ellipsePath(cx: number, cy: number, rx: number, ry: number, angle = 0): string {\n if (!(rx > 0) || !(ry > 0) || !Number.isFinite(cx + cy + rx + ry + angle)) return \"\";\n const dx = rx * Math.cos(angle);\n const dy = rx * Math.sin(angle);\n const degrees = round((angle * 180) / Math.PI);\n const arc = `A${round(rx)} ${round(ry)} ${degrees} 1 0`;\n return `M${round(cx + dx)} ${round(cy + dy)}${arc} ${round(cx - dx)} ${round(cy - dy)}${arc} ${round(cx + dx)} ${round(cy + dy)}`;\n}\n","/**\n * Many ellipses over the image whose size is data: fitted ring edges, edge-bit dots.\n *\n * A `MarkerShape` is sized in screen pixels, so it cannot draw a ring whose radius is a\n * measurement. This layer draws exact ellipses (two arcs each) in image pixels, batched by\n * appearance into a handful of `<path>`s (ADR-0004 rule 1). Strokes stay screen-sized (rule 4).\n * It is not picked: pair it with a `PointSet` at the centres, which is what `TargetOverlay` does.\n */\n\nimport {\n OVERLAY_STATE_OPACITY,\n OVERLAY_STATE_WIDTH,\n imageViewBox,\n overlayRole,\n useScreenPx,\n useStage,\n type OverlayRole,\n} from \"@vitavision/stage2d\";\nimport { useMemo } from \"react\";\n\nimport { ellipsePath } from \"./glyphs\";\nimport type { TargetId } from \"./model\";\n\n/** One ellipse of an `EllipseSet`. */\nexport interface EllipseSetItem {\n /** Its identity, for hover, selection and dimming. */\n id: TargetId;\n /** Centre x, image pixels. */\n x: number;\n /** Centre y, image pixels. */\n y: number;\n /** Semi-axis along the rotated x axis, image pixels. */\n rx: number;\n /** Semi-axis along the rotated y axis, image pixels. */\n ry: number;\n /** Rotation of the `rx` axis, radians clockwise on screen. Defaults to 0. */\n angle?: number | undefined;\n /** The overlay role it is painted in. Defaults to the layer's `role`. */\n role?: OverlayRole | undefined;\n /** Draw it dashed (4 3 screen px), so two kinds differ by more than colour. */\n dashed?: boolean | undefined;\n /** Opacity in [0, 1], rounded to a tenth so ellipses still share paths. Defaults to 1. */\n opacity?: number | undefined;\n}\n\n/** Props of `EllipseSet`. */\nexport interface EllipseSetProps {\n /** The ellipses, in image coordinates. */\n items: readonly EllipseSetItem[];\n /** The role of an item that names none. Defaults to `\"feature\"`. */\n role?: OverlayRole | undefined;\n /** The hovered id: its ellipses are drawn at 2 px. */\n hoveredId?: TargetId | null | undefined;\n /** The selected ids, drawn at 2.5 px in the selection colour. */\n selectedIds?: Iterable<TargetId> | undefined;\n /** Ids drawn at 35 % opacity, as a set or a predicate. Pass a stable value: a new one re-batches the layer. */\n dimmed?: Iterable<TargetId> | ((id: TargetId) => boolean) | undefined;\n /** Draw the dark band under every stroke. On by default. */\n halo?: boolean | undefined;\n /**\n * The smallest semi-axis, in screen pixels: a dot whose data size would vanish at the fitted\n * zoom is still drawn this large. Omit for none.\n */\n minRadius?: number | undefined;\n /** CSS colour of selected ellipses. Defaults to the overlay `selection` role. */\n selectionStroke?: string | undefined;\n /** Name the layer as an image for assistive technology. Without it the layer is decorative (`aria-hidden`). */\n label?: string | undefined;\n}\n\nconst HALO = overlayRole(\"halo\");\n\n/** The outline of an item, its semi-axes raised to `floor` image pixels. */\nfunction outlineOf(item: EllipseSetItem, floor: number): string {\n return ellipsePath(item.x, item.y, Math.max(item.rx, floor), Math.max(item.ry, floor), item.angle ?? 0);\n}\n\n/** The concatenated outlines of the items at `indices`. */\nfunction batchPath(items: readonly EllipseSetItem[], indices: readonly number[], floor: number): string {\n let d = \"\";\n for (const i of indices) d += outlineOf(items[i]!, floor);\n return d;\n}\n\n/** The ellipses of one batched path. */\ninterface Batch {\n key: string;\n role: OverlayRole;\n dashed: boolean;\n opacity: number;\n dim: boolean;\n /** Item positions, ascending. */\n indices: number[];\n}\n\n/**\n * A batched set of ellipses inside an `ImageStage`.\n *\n * - **Geometry** is data: `rx`, `ry` and the centre are image pixels and scale with the image;\n * the stroke is a screen constant.\n * - **States** follow visual-language §5: 1.5 screen px (1 for `model` and `structure`), hover\n * 2, selected 2.5 in the selection colour, dimmed at 35 % opacity. Every stroke has a halo.\n * - **Batching** is by (role, dash, opacity, dimming): a thousand rings are a dozen elements.\n *\n * The SVG carries `data-ellipses` (the count).\n */\nexport function EllipseSet({\n items,\n role = \"feature\",\n hoveredId = null,\n selectedIds,\n dimmed,\n halo = true,\n minRadius,\n selectionStroke = overlayRole(\"selection\"),\n label,\n}: EllipseSetProps) {\n const stage = useStage();\n const px = useScreenPx();\n const unit = px(1);\n\n const selectedSet = useMemo(() => new Set(selectedIds ?? []), [selectedIds]);\n const isDimmed = useMemo(() => {\n if (typeof dimmed === \"function\") return dimmed;\n const set = new Set(dimmed ?? []);\n return (id: TargetId) => set.has(id);\n }, [dimmed]);\n\n const batches = useMemo(() => {\n const normal = new Map<string, Batch>();\n const picked: Batch = { key: \"selected\", role: \"selection\", dashed: false, opacity: 1, dim: false, indices: [] };\n items.forEach((item, i) => {\n if (selectedSet.has(item.id)) {\n picked.indices.push(i);\n return;\n }\n const itemRole = item.role ?? role;\n const dashed = item.dashed ?? false;\n const opacity = Math.round(Math.min(1, Math.max(0, item.opacity ?? 1)) * 10) / 10;\n const dim = isDimmed(item.id);\n const key = `${dim ? 1 : 0}|${itemRole}|${dashed ? \"dashed\" : \"solid\"}|${opacity}`;\n let batch = normal.get(key);\n if (!batch) {\n batch = { key, role: itemRole, dashed, opacity, dim, indices: [] };\n normal.set(key, batch);\n }\n batch.indices.push(i);\n });\n return { normal: [...normal.values()], picked: picked.indices.length > 0 ? picked : null };\n }, [items, role, selectedSet, isDimmed]);\n\n // Outlines depend on the zoom only through the screen-pixel floor.\n const floor = minRadius !== undefined ? minRadius * unit : 0;\n const normalPaths = useMemo(\n () => batches.normal.map((batch) => ({ batch, d: batchPath(items, batch.indices, floor) })),\n [batches, items, floor],\n );\n const pickedPath = useMemo(() => (batches.picked ? batchPath(items, batches.picked.indices, floor) : \"\"), [batches, items, floor]);\n\n const hoverPositions: number[] = [];\n if (hoveredId !== null) {\n items.forEach((item, i) => {\n if (item.id === hoveredId) hoverPositions.push(i);\n });\n }\n const hoverSelected = hoveredId !== null && selectedSet.has(hoveredId);\n\n const widthOf = (itemRole: OverlayRole, state: \"default\" | \"hover\" | \"selected\"): number => {\n const thin = itemRole === \"model\" || itemRole === \"structure\";\n return px(OVERLAY_STATE_WIDTH[state] - (thin && state !== \"selected\" ? 0.5 : 0));\n };\n const dash = `${px(4)} ${px(3)}`;\n\n return (\n <svg\n viewBox={imageViewBox(stage.image)}\n className=\"pointer-events-none absolute inset-0 h-full w-full overflow-visible\"\n {...(label !== undefined ? { role: \"img\", \"aria-label\": label } : { \"aria-hidden\": true })}\n data-ellipses={items.length}\n >\n <g fill=\"none\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n {normalPaths.map(({ batch, d }) => (\n <g key={batch.key} opacity={batch.dim ? OVERLAY_STATE_OPACITY.dimmed : undefined}>\n {halo && (\n <path\n d={d}\n stroke={HALO}\n strokeWidth={widthOf(batch.role, \"default\") + px(2)}\n strokeDasharray={batch.dashed ? dash : undefined}\n opacity={0.6 * batch.opacity}\n />\n )}\n <path\n data-batch={batch.key}\n d={d}\n stroke={overlayRole(batch.role)}\n strokeWidth={widthOf(batch.role, \"default\")}\n strokeDasharray={batch.dashed ? dash : undefined}\n opacity={batch.opacity}\n />\n </g>\n ))}\n {batches.picked && (\n <>\n {halo && <path d={pickedPath} stroke={HALO} strokeWidth={widthOf(\"selection\", \"selected\") + px(2)} />}\n <path data-selected-ellipses=\"\" d={pickedPath} stroke={selectionStroke} strokeWidth={widthOf(\"selection\", \"selected\")} />\n </>\n )}\n {hoverPositions.map((position) => {\n const item = items[position]!;\n const itemRole = item.role ?? role;\n const state = hoverSelected ? \"selected\" : \"hover\";\n return (\n <g key={position}>\n {halo && <path d={outlineOf(item, floor)} stroke={HALO} strokeWidth={widthOf(itemRole, state) + px(2)} />}\n <path\n data-hovered-ellipse=\"\"\n d={outlineOf(item, floor)}\n stroke={hoverSelected ? selectionStroke : overlayRole(itemRole)}\n strokeWidth={widthOf(itemRole, state)}\n />\n </g>\n );\n })}\n </g>\n </svg>\n );\n}\n","/**\n * The lattice of a detected board: which corner sits at which `(i, j)`, which corners are\n * neighbours, and the polygons of the markers.\n *\n * Ported from vitavision's `overlayData.ts` (`buildCornerGrid`, `buildGridEdges`,\n * `buildFeatureIdByGrid`, `buildMarkerPolygons`), where ChArUco, chessboard, marker board and\n * PuzzleBoard each carried a copy (PuzzleBoard's `buildPuzzleGrid` was a fourth). One\n * implementation now serves all four, on the normalised `TargetDetection` input.\n *\n * Pure: no React, no DOM.\n */\n\nimport { latticeEdges } from \"@vitavision/stage2d\";\n\nimport type { TargetCorner, TargetId, TargetMarker } from \"./model\";\n\n/** A corner that has a place on the board. */\nexport type GridCorner = TargetCorner & { i: number; j: number };\n\n/** The extent of a lattice, inclusive. */\nexport interface GridBounds {\n /** Smallest `i`. */\n minI: number;\n /** Largest `i`. */\n maxI: number;\n /** Smallest `j`. */\n minJ: number;\n /** Largest `j`. */\n maxJ: number;\n}\n\n/** The corners of a board, indexed by lattice position. */\nexport interface CornerGrid {\n /** The corners with an integer `(i, j)`, in input order. A repeated `(i, j)` keeps its first corner. */\n nodes: readonly GridCorner[];\n /** Position in `nodes` by `gridKey(i, j)`. */\n byIndex: ReadonlyMap<string, number>;\n /** Positions in `nodes` grouped by `i` (ascending), each group sorted by `j`. */\n rows: readonly (readonly number[])[];\n /** Positions in `nodes` grouped by `j` (ascending), each group sorted by `i`. */\n cols: readonly (readonly number[])[];\n /** The extent, or `null` for an empty grid. */\n bounds: GridBounds | null;\n}\n\n/** A segment between two neighbouring corners. */\nexport interface GridSegment {\n /** Id of the end with the lower index along the edge's axis. */\n a: TargetId;\n /** Id of the end with the higher index. */\n b: TargetId;\n /** Start x. */\n x1: number;\n /** Start y. */\n y1: number;\n /** End x. */\n x2: number;\n /** End y. */\n y2: number;\n}\n\n/** A marker as a closed polygon. */\nexport interface MarkerPolygon {\n /** The marker's id. */\n id: TargetId;\n /** Flat `[x0, y0, x1, y1, …]`; the last vertex joins the first. */\n points: number[];\n /** The mean of the vertices. */\n centre: { x: number; y: number };\n /** The marker's own label, if it has one. */\n label?: string | undefined;\n}\n\n/**\n * The key of a lattice position, as `idByGrid` and `CornerGrid.byIndex` use.\n *\n * @param i - Index along the first axis.\n * @param j - Index along the second axis.\n * @returns `\"i:j\"`.\n */\nexport function gridKey(i: number, j: number): string {\n return `${i}:${j}`;\n}\n\n/** Whether a corner carries an integer lattice index. */\nfunction isGridCorner(corner: TargetCorner): corner is GridCorner {\n return Number.isInteger(corner.i) && Number.isInteger(corner.j);\n}\n\n/**\n * Index a board's corners by lattice position.\n *\n * Corners without an integer `(i, j)` are not part of the grid. When two corners claim one\n * position the first wins, as it does in `latticeEdges`.\n *\n * @param corners - The detected corners, in any order, with gaps allowed.\n * @returns The grid.\n */\nexport function cornerGrid(corners: readonly TargetCorner[]): CornerGrid {\n const nodes: GridCorner[] = [];\n const byIndex = new Map<string, number>();\n const rowMap = new Map<number, number[]>();\n const colMap = new Map<number, number[]>();\n let bounds: GridBounds | null = null;\n\n for (const corner of corners) {\n if (!isGridCorner(corner)) continue;\n const key = gridKey(corner.i, corner.j);\n if (byIndex.has(key)) continue;\n const position = nodes.length;\n nodes.push(corner);\n byIndex.set(key, position);\n const row = rowMap.get(corner.i);\n if (row) row.push(position);\n else rowMap.set(corner.i, [position]);\n const col = colMap.get(corner.j);\n if (col) col.push(position);\n else colMap.set(corner.j, [position]);\n bounds = bounds\n ? {\n minI: Math.min(bounds.minI, corner.i),\n maxI: Math.max(bounds.maxI, corner.i),\n minJ: Math.min(bounds.minJ, corner.j),\n maxJ: Math.max(bounds.maxJ, corner.j),\n }\n : { minI: corner.i, maxI: corner.i, minJ: corner.j, maxJ: corner.j };\n }\n\n const ordered = (groups: Map<number, number[]>, by: \"i\" | \"j\") =>\n [...groups.entries()]\n .sort(([a], [b]) => a - b)\n .map(([, group]) => group.sort((p, q) => nodes[p]![by] - nodes[q]![by]));\n return { nodes, byIndex, rows: ordered(rowMap, \"j\"), cols: ordered(colMap, \"i\"), bounds };\n}\n\n/**\n * The edges between neighbouring corners of a grid: `(i, j)` to `(i, j + 1)` are the row edges,\n * `(i, j)` to `(i + 1, j)` the column edges. A missed corner leaves a gap, never a long edge.\n * It is `latticeEdges` from `@vitavision/stage2d` with positions attached.\n *\n * @param grid - From `cornerGrid`.\n * @returns The two edge lists.\n */\nexport function gridEdges(grid: CornerGrid): { rowEdges: GridSegment[]; colEdges: GridSegment[] } {\n const rowEdges: GridSegment[] = [];\n const colEdges: GridSegment[] = [];\n for (const edge of latticeEdges(grid.nodes)) {\n const a = grid.nodes[edge.a]!;\n const b = grid.nodes[edge.b]!;\n (edge.axis === \"j\" ? rowEdges : colEdges).push({ a: a.id, b: b.id, x1: a.x, y1: a.y, x2: b.x, y2: b.y });\n }\n return { rowEdges, colEdges };\n}\n\n/**\n * The id of the corner at each lattice position, to map a board cell back to an app's feature.\n *\n * @param corners - The detected corners.\n * @returns Ids by `gridKey(i, j)`. A corner without an integer index is left out; the first of two sharing a position wins.\n */\nexport function idByGrid(corners: readonly TargetCorner[]): Map<string, TargetId> {\n const map = new Map<string, TargetId>();\n for (const corner of corners) {\n if (!isGridCorner(corner)) continue;\n const key = gridKey(corner.i, corner.j);\n if (!map.has(key)) map.set(key, corner.id);\n }\n return map;\n}\n\n/**\n * The markers as polygons, with their centres.\n *\n * @param markers - The detected markers.\n * @returns A polygon per marker that has at least three finite vertices; the others are dropped.\n */\nexport function markerPolygons(markers: readonly TargetMarker[]): MarkerPolygon[] {\n const out: MarkerPolygon[] = [];\n for (const marker of markers) {\n const n = marker.corners.length;\n if (n < 6 || n % 2 !== 0 || !marker.corners.every(Number.isFinite)) continue;\n let sx = 0;\n let sy = 0;\n for (let k = 0; k < n; k += 2) {\n sx += marker.corners[k]!;\n sy += marker.corners[k + 1]!;\n }\n const polygon: MarkerPolygon = {\n id: marker.id,\n points: [...marker.corners],\n centre: { x: sx / (n / 2), y: sy / (n / 2) },\n };\n if (marker.label !== undefined) polygon.label = marker.label;\n out.push(polygon);\n }\n return out;\n}\n","/**\n * The input model: one detection run, independent of the library that produced it.\n *\n * Every detector in the vitavision family (calib-targets' chessboard, ChArUco, marker board and\n * PuzzleBoard, ringgrid, chess-corners) returns its own result shape. An app maps that shape to a\n * `TargetDetection` once, and the overlay never learns which library ran. Nothing here imports a\n * detector package: these are plain data types.\n *\n * Conventions, the same as `@vitavision/stage2d`:\n * - Positions are **image pixels, with the centre of pixel `i` at coordinate `i`** (the frame\n * the WASM detectors report, `image_px_center`). The stage places them; do not add 0.5.\n * - `y` points down. Angles are **radians, clockwise on screen** (from +x towards +y).\n * - Lengths named `rx`, `ry` and `radius` are image pixels, so they scale with the image.\n *\n * Pure: no React, no DOM.\n */\n\n/** An item's identity. Ids are unique within one detection, across corners, markers, circles and rings. */\nexport type TargetId = string | number;\n\n/** What a detection is of. It chooses defaults, not what is drawn: whatever is present is drawn. */\nexport type TargetKind =\n | \"chessboard\"\n | \"charuco\"\n | \"markerboard\"\n | \"puzzleboard\"\n | \"ringgrid\"\n | \"corners\"\n | \"circles\";\n\n/** Every `TargetKind`. */\nexport const TARGET_KINDS: readonly TargetKind[] = [\n \"chessboard\",\n \"charuco\",\n \"markerboard\",\n \"puzzleboard\",\n \"ringgrid\",\n \"corners\",\n \"circles\",\n];\n\n/** The kinds whose corners form a lattice, so their neighbours are joined by edges. */\nconst LATTICE_KINDS: ReadonlySet<TargetKind> = new Set([\"chessboard\", \"charuco\", \"markerboard\", \"puzzleboard\"]);\n\n/**\n * Whether a detection of this kind draws lattice edges between corner neighbours.\n *\n * @param kind - The detection's kind.\n * @returns `true` for the four calibration boards, `false` for loose corners, circles and rings.\n */\nexport function isLatticeKind(kind: TargetKind): boolean {\n return LATTICE_KINDS.has(kind);\n}\n\n/** One detected corner or X-junction. */\nexport interface TargetCorner {\n /** Its identity. Callbacks report this id back. */\n id: TargetId;\n /** Horizontal position, image pixels. */\n x: number;\n /** Vertical position, image pixels. */\n y: number;\n /** Lattice index along the first board axis, an integer. Absent for a corner with no place on a board. */\n i?: number | undefined;\n /** Lattice index along the second board axis, an integer. */\n j?: number | undefined;\n /**\n * The detector's confidence. It is carried for the app (a list, a filter) and never drawn as a\n * colour: a score is not a verdict (visual-language §5).\n */\n score?: number | undefined;\n /** Orientation of the first edge through the corner, radians. Axes are lines, so `angle` and `angle + π` are the same. */\n angle?: number | undefined;\n /** Orientation of the second edge through the corner, radians. Needs `angle`. */\n angle2?: number | undefined;\n /** Text beside it. Defaults to the lattice index `i,j` on a board, else the id. */\n label?: string | undefined;\n}\n\n/** One decoded fiducial marker (ArUco, AprilTag): a quad. */\nexport interface TargetMarker {\n /** Its identity. For an ArUco marker, usually its dictionary id. */\n id: TargetId;\n /**\n * The quad's corners in the marker's own order, `[x0, y0, x1, y1, x2, y2, x3, y3]`. Corner 0 is\n * ticked, so the order reads as the marker's orientation.\n */\n corners: readonly number[];\n /** Text drawn inside it. Defaults to the id. */\n label?: string | undefined;\n}\n\n/** The printed colour of a circle in a marker board. */\nexport type CirclePolarity = \"white\" | \"black\";\n\n/** One detected circle of a marker board, matched or not to the board model. */\nexport interface TargetCircle {\n /** Its identity. */\n id: TargetId;\n /** Centre x, image pixels. */\n x: number;\n /** Centre y, image pixels. */\n y: number;\n /** Printed polarity. It is drawn as a shape (hollow ring, or ring with a centre dot), not as a colour. */\n polarity: CirclePolarity;\n /** The board cell it matched, first axis. */\n i?: number | undefined;\n /** The board cell it matched, second axis. */\n j?: number | undefined;\n /** Text beside it. Defaults to `(i, j)` when both are set. */\n label?: string | undefined;\n}\n\n/** A fitted ellipse. */\nexport interface TargetEllipse {\n /** Semi-axis along the rotated x axis, image pixels. */\n rx: number;\n /** Semi-axis along the rotated y axis, image pixels. */\n ry: number;\n /** Rotation of the `rx` axis, radians clockwise on screen. */\n angle: number;\n}\n\n/** One ring marker of a ring grid: two concentric fitted ellipses and a centre. */\nexport interface TargetRing {\n /** Its identity. */\n id: TargetId;\n /** Centre x, image pixels. */\n x: number;\n /** Centre y, image pixels. */\n y: number;\n /** The outer edge of the ring. */\n outer: TargetEllipse;\n /** The inner edge of the ring, when the detector fitted one. */\n inner?: TargetEllipse | undefined;\n /** Text beside the centre. Defaults to the id. */\n label?: string | undefined;\n}\n\n/**\n * One decoded bit of a PuzzleBoard, drawn as a dot on the edge between two corners.\n * `edgeBitsFromPuzzleboard` builds these from a PuzzleBoard result.\n */\nexport interface TargetEdgeBit {\n /** Its identity. Not reported by callbacks: edge bits are not picked. */\n id: TargetId;\n /** Midpoint x of the edge, image pixels. */\n x: number;\n /** Midpoint y of the edge, image pixels. */\n y: number;\n /** The dot's radius, image pixels: about a quarter of the edge. */\n radius: number;\n /** The decoded bit. 1 is a solid dot, 0 a dashed one. */\n bit: 0 | 1;\n /** Decode confidence in [0, 1]. It sets the dot's opacity. */\n confidence: number;\n}\n\n/** One detection run: what a detector found in one image. */\nexport interface TargetDetection {\n /** What was detected. */\n kind: TargetKind;\n /** Corners and X-junctions. */\n corners?: readonly TargetCorner[] | undefined;\n /** Decoded fiducial markers. */\n markers?: readonly TargetMarker[] | undefined;\n /** Marker-board circles. */\n circles?: readonly TargetCircle[] | undefined;\n /** Ring markers. */\n rings?: readonly TargetRing[] | undefined;\n /** PuzzleBoard edge bits. */\n edgeBits?: readonly TargetEdgeBit[] | undefined;\n}\n\n/** The part of a detection an item belongs to. */\nexport type TargetPart = \"corner\" | \"marker\" | \"circle\" | \"ring\";\n\n/** Which item the pointer is on. */\nexport interface TargetHit {\n /** The item's id, as given in the detection. */\n id: TargetId;\n /** The collection it came from. */\n part: TargetPart;\n}\n","/**\n * What each stage2d layer is given, for each part of a detection: the pure mapping from the\n * normalised `TargetDetection` to the items of `GridLayer`, `AreaSet`, `PointSet` and\n * `EllipseSet`. `TargetOverlay` is these plus the wiring, so this is where the overlay's\n * decisions are, and where they are tested without a DOM.\n *\n * Pure: no React, no DOM.\n */\n\nimport type { AreaSetItem, GridNode, PointSetItem } from \"@vitavision/stage2d\";\n\nimport type { EllipseSetItem } from \"./EllipseSet\";\nimport { packAxes } from \"./glyphs\";\nimport { markerPolygons } from \"./lattice\";\nimport { isLatticeKind, type TargetCircle, type TargetCorner, type TargetDetection, type TargetEdgeBit, type TargetRing } from \"./model\";\n\n/** The label of a corner: its own, else the lattice index on a board, else the id. */\nfunction cornerLabel(corner: TargetCorner, lattice: boolean): string {\n if (corner.label !== undefined) return corner.label;\n if (lattice && Number.isInteger(corner.i) && Number.isInteger(corner.j)) return `${corner.i},${corner.j}`;\n return String(corner.id);\n}\n\n/**\n * The nodes of the corner layer.\n *\n * A corner with an `angle` is a `directed` marker (its edge directions, one or two), any other a\n * `plus`. On a board kind the lattice indices are kept, so `GridLayer` joins neighbours; on any\n * other kind they are `NaN`, which `latticeEdges` reads as \"not part of a lattice\", so no edge is\n * drawn.\n *\n * @param detection - The detection.\n * @returns One node per corner, in order.\n */\nexport function cornerNodes(detection: TargetDetection): GridNode[] {\n const lattice = isLatticeKind(detection.kind);\n return (detection.corners ?? []).map((corner): GridNode => {\n const node: GridNode = {\n id: corner.id,\n x: corner.x,\n y: corner.y,\n i: lattice && Number.isInteger(corner.i) ? corner.i! : Number.NaN,\n j: lattice && Number.isInteger(corner.j) ? corner.j! : Number.NaN,\n label: cornerLabel(corner, lattice),\n };\n if (corner.angle !== undefined) {\n node.kind = \"directed\";\n node.angle = packAxes(corner.angle, corner.angle2);\n }\n return node;\n });\n}\n\n/**\n * The regions of the marker layer: each marker's quad, labelled with its text or its id.\n *\n * @param detection - The detection.\n * @returns One area per marker with a usable quad.\n */\nexport function markerAreas(detection: TargetDetection): AreaSetItem[] {\n return markerPolygons(detection.markers ?? []).map((polygon) => ({\n id: polygon.id,\n points: polygon.points,\n label: polygon.label ?? String(polygon.id),\n }));\n}\n\n/** The label of a circle: its own, else `(i, j)` when it matched a cell. */\nfunction circleLabel(circle: TargetCircle): string | undefined {\n if (circle.label !== undefined) return circle.label;\n return Number.isInteger(circle.i) && Number.isInteger(circle.j) ? `(${circle.i}, ${circle.j})` : undefined;\n}\n\n/**\n * The points of the circle layer. Polarity picks the glyph: `circle-white` is a hollow ring,\n * `circle-black` a ring with a dot.\n *\n * @param detection - The detection.\n * @returns One point per circle.\n */\nexport function circlePoints(detection: TargetDetection): PointSetItem[] {\n return (detection.circles ?? []).map((circle) => {\n const item: PointSetItem = { id: circle.id, x: circle.x, y: circle.y, kind: `circle-${circle.polarity}` };\n const label = circleLabel(circle);\n if (label !== undefined) item.label = label;\n return item;\n });\n}\n\n/**\n * The points of the ring layer: a `plus` at each centre, picked anywhere inside the outer ellipse\n * (`pickRadius` is the larger semi-axis), labelled with the ring's text or its id.\n *\n * @param rings - The rings.\n * @returns One point per ring.\n */\nexport function ringCentres(rings: readonly TargetRing[]): PointSetItem[] {\n return rings.map((ring) => ({\n id: ring.id,\n x: ring.x,\n y: ring.y,\n kind: \"plus\",\n pickRadius: Math.max(ring.outer.rx, ring.outer.ry),\n label: ring.label ?? String(ring.id),\n }));\n}\n\n/**\n * The ellipses of the rings' two edges. The outer is `feature`, the inner `model` (a fitted\n * second edge), and the smaller inner one is told from the outer by size as well as by colour.\n *\n * @param rings - The rings.\n * @returns The outer ellipses, and the inner ones of the rings that have one.\n */\nexport function ringEllipses(rings: readonly TargetRing[]): { outer: EllipseSetItem[]; inner: EllipseSetItem[] } {\n const outer: EllipseSetItem[] = [];\n const inner: EllipseSetItem[] = [];\n for (const ring of rings) {\n outer.push({ id: ring.id, x: ring.x, y: ring.y, rx: ring.outer.rx, ry: ring.outer.ry, angle: ring.outer.angle, role: \"feature\" });\n if (ring.inner) {\n inner.push({ id: ring.id, x: ring.x, y: ring.y, rx: ring.inner.rx, ry: ring.inner.ry, angle: ring.inner.angle, role: \"model\" });\n }\n }\n return { outer, inner };\n}\n\n/** Opacity of a dot at confidence 0 and at confidence 1: a weak bit is visible, a sure one is solid. */\nconst BIT_OPACITY_MIN = 0.35;\n\n/**\n * The dots of the edge-bit layer: bit 1 is a solid `feature` circle, bit 0 a dashed `model`\n * one, and the opacity runs from 35 % at confidence 0 to 100 % at confidence 1.\n *\n * @param bits - The edge bits.\n * @returns One ellipse (a circle) per bit.\n */\nexport function edgeBitEllipses(bits: readonly TargetEdgeBit[]): EllipseSetItem[] {\n return bits.map((bit) => ({\n id: bit.id,\n x: bit.x,\n y: bit.y,\n rx: bit.radius,\n ry: bit.radius,\n role: bit.bit === 1 ? \"feature\" : \"model\",\n dashed: bit.bit === 0,\n opacity: BIT_OPACITY_MIN + (1 - BIT_OPACITY_MIN) * Math.min(1, Math.max(0, bit.confidence)),\n }));\n}\n","/**\n * A calibration-target detection over the image: one component for a chessboard, ChArUco,\n * marker board, PuzzleBoard, ring grid or a loose set of corners.\n *\n * It replaces the per-board overlays of vitavision (`ChessboardOverlay`, `CharucoOverlay`,\n * `MarkerboardOverlay`, `PuzzleboardOverlay`) and the glyph components behind them. Each part of\n * a `TargetDetection` goes to the stage2d layer that fits it, so a detection of thousands of\n * items is a few dozen DOM nodes (ADR-0004), and the pointer is resolved by the stage's hit-test\n * registry, not the DOM:\n *\n * | Part | Layer | Glyph (visual-language §5) |\n * |---|---|---|\n * | `corners` | `GridLayer` | plus; edge directions when `angle` is set; lattice edges and `i,j` labels |\n * | `markers` | `AreaSet` | quad outline and 12 % fill, corner 0 ticked, id inside |\n * | `circles` | `PointSet` | ring; a centre dot marks black |\n * | `rings` | `PointSet` + `EllipseSet` | fitted outer and inner ellipse, plus at the centre |\n * | `edgeBits` | `EllipseSet` | dot on the edge: solid for 1, dashed for 0, opacity from confidence |\n */\n\nimport {\n GridLayer,\n AreaSet,\n PointSet,\n type StagePointerEvent,\n} from \"@vitavision/stage2d\";\nimport { useCallback, useLayoutEffect, useMemo, useRef, useState } from \"react\";\n\nimport { EllipseSet } from \"./EllipseSet\";\nimport { TARGET_MARKERS } from \"./glyphs\";\nimport { circlePoints, cornerNodes, edgeBitEllipses, markerAreas, ringCentres, ringEllipses } from \"./layerItems\";\nimport type { TargetDetection, TargetHit, TargetId, TargetPart } from \"./model\";\n\n/** Props of `TargetOverlay`. */\nexport interface TargetOverlayProps {\n /** The detection to draw. Pass a stable object: a new one rebuilds every layer's index. */\n detection: TargetDetection;\n /** Draw the lattice edges between neighbouring corners, one dashed axis and one solid. On by default. */\n showEdges?: boolean | undefined;\n /** Show labels (lattice indices, marker ids, ring ids) where the zoom leaves room for them. On by default. */\n showLabels?: boolean | undefined;\n /**\n * The hovered id, when the app controls hover (a list beside the stage hovers items too). It\n * applies to every part that has the id; keep ids unique within a detection.\n */\n hoveredId?: TargetId | null | undefined;\n /** The selected ids, drawn at 2.5 px in the selection colour; points get a ring. */\n selectedIds?: Iterable<TargetId> | undefined;\n /**\n * Called when the item under the pointer changes, once per change; `null` when it leaves every\n * item. The `id` is the one given in the detection, so the app maps it back to its feature.\n */\n onHoverChange?: ((hit: TargetHit | null) => void) | undefined;\n /**\n * A press landed on an item. Setting it makes the layers claim presses on their items, so the\n * stage does not pan from them. A mounted `StageSurface` hears a press first; there, ask\n * `useStageHitTest` what is under it instead.\n */\n onItemPress?: ((hit: TargetHit, event: StagePointerEvent) => void) | undefined;\n /**\n * Dim the whole overlay (`true`), or the listed ids, or those a predicate accepts, to 35 %\n * opacity. They still take hover and presses. Pass a stable value: a new one re-batches.\n */\n dimmed?: boolean | Iterable<TargetId> | ((id: TargetId) => boolean) | undefined;\n /** Prefix of the hit-test layer ids (`<prefix>-corners`, `-markers`, `-circles`, `-rings`). Defaults to generated ids. */\n layerIdPrefix?: string | undefined;\n}\n\n/** The ids of each part, to route a hovered or selected id to the layers that have it. */\nfunction idsByPart(detection: TargetDetection): Record<TargetPart, ReadonlySet<TargetId>> {\n const ids = (items: readonly { id: TargetId }[] | undefined) => new Set((items ?? []).map((item) => item.id));\n return {\n corner: ids(detection.corners),\n marker: ids(detection.markers),\n circle: ids(detection.circles),\n ring: ids(detection.rings),\n };\n}\n\n/** The `dimmed` prop as the predicate the layers take, or `undefined` for none. */\nfunction dimPredicate(dimmed: TargetOverlayProps[\"dimmed\"]): ((id: TargetId) => boolean) | undefined {\n if (dimmed === undefined || dimmed === false) return undefined;\n if (dimmed === true) return () => true;\n if (typeof dimmed === \"function\") return dimmed;\n const set = new Set(dimmed);\n return (id) => set.has(id);\n}\n\n/**\n * A detected calibration target inside an `ImageStage`.\n *\n * - **Batched**: one path per appearance in each layer, picking through spatial indices. Labels\n * appear only where items are 24 screen px apart, at most 200 at a time.\n * - **States**: hover 2 px, selected 2.5 px in the selection colour with a ring, dimmed at 35 %.\n * - **Colour**: roles only (`feature`, `model`, `structure`, `selection`). Scores are never drawn\n * as red, amber or green; polarity and bits are carried by shape (hollow or dotted, solid or\n * dashed), not by hue.\n * - **Callbacks** report `{ id, part }` with the id from the detection. A press and a hover move\n * between layers (a corner, then the marker under it) without a flicker: the change is reported\n * once.\n *\n * The layers it renders carry their own accessible names (\"Corners: 54 points, 0 selected\").\n */\nexport function TargetOverlay({\n detection,\n showEdges = true,\n showLabels = true,\n hoveredId,\n selectedIds,\n onHoverChange,\n onItemPress,\n dimmed,\n layerIdPrefix,\n}: TargetOverlayProps) {\n const nodes = useMemo(() => cornerNodes(detection), [detection]);\n const areas = useMemo(() => markerAreas(detection), [detection]);\n const circles = useMemo(() => circlePoints(detection), [detection]);\n const rings = detection.rings;\n const ringPoints = useMemo(() => ringCentres(rings ?? []), [rings]);\n const ringShapes = useMemo(() => ringEllipses(rings ?? []), [rings]);\n const bits = useMemo(() => edgeBitEllipses(detection.edgeBits ?? []), [detection.edgeBits]);\n const ids = useMemo(() => idsByPart(detection), [detection]);\n\n // Selection and hover are by id; each layer is given the ids it owns, so its count is right.\n const selectedSet = useMemo(() => new Set(selectedIds ?? []), [selectedIds]);\n const selected = useMemo(() => {\n const pick = (part: TargetPart) => new Set([...selectedSet].filter((id) => ids[part].has(id)));\n return { corner: pick(\"corner\"), marker: pick(\"marker\"), circle: pick(\"circle\"), ring: pick(\"ring\") };\n }, [selectedSet, ids]);\n const isDimmed = useMemo(() => dimPredicate(dimmed), [dimmed]);\n\n // Hover. The layers report separately, so moving from a corner to the marker under it is\n // `corner → null` then `marker → id` in one event. The net result is read when the event is\n // done, and reported once.\n const [ownHover, setOwnHover] = useState<TargetHit | null>(null);\n const hoverRef = useRef<TargetHit | null>(null);\n const reportedRef = useRef<TargetHit | null>(null);\n const scheduledRef = useRef(false);\n const onHoverChangeRef = useRef(onHoverChange);\n useLayoutEffect(() => {\n onHoverChangeRef.current = onHoverChange;\n });\n const hoverFrom = useCallback((part: TargetPart) => (id: TargetId | null) => {\n if (id !== null) hoverRef.current = { id, part };\n else if (hoverRef.current?.part === part) hoverRef.current = null;\n setOwnHover(hoverRef.current);\n if (scheduledRef.current) return;\n scheduledRef.current = true;\n queueMicrotask(() => {\n scheduledRef.current = false;\n const now = hoverRef.current;\n const before = reportedRef.current;\n if (now?.id === before?.id && now?.part === before?.part) return;\n reportedRef.current = now;\n onHoverChangeRef.current?.(now);\n });\n }, []);\n const hoverOf = (part: TargetPart): TargetId | null => {\n if (hoveredId !== undefined) return hoveredId !== null && ids[part].has(hoveredId) ? hoveredId : null;\n return ownHover?.part === part ? ownHover.id : null;\n };\n\n const pressFrom = (part: TargetPart) =>\n onItemPress ? (id: TargetId, event: StagePointerEvent) => onItemPress({ id, part }, event) : undefined;\n const layerId = (name: string) => (layerIdPrefix === undefined ? undefined : `${layerIdPrefix}-${name}`);\n\n const hasCorners = nodes.length > 0;\n const hasMarkers = areas.length > 0;\n const hasCircles = circles.length > 0;\n const hasRings = ringPoints.length > 0;\n const edgeStyle = { visible: showEdges };\n\n return (\n <>\n {hasMarkers && (\n <AreaSet\n items={areas}\n firstVertexTick\n labels={showLabels}\n hoveredId={hoverOf(\"marker\")}\n selectedIds={selected.marker}\n dimmed={isDimmed}\n onHoverChange={hoverFrom(\"marker\")}\n onItemPress={pressFrom(\"marker\")}\n layerId={layerId(\"markers\")}\n label=\"Markers\"\n />\n )}\n {bits.length > 0 && <EllipseSet items={bits} minRadius={3} dimmed={isDimmed} />}\n {hasRings && (\n <>\n <EllipseSet items={ringShapes.outer} hoveredId={hoverOf(\"ring\")} selectedIds={selected.ring} dimmed={isDimmed} />\n {ringShapes.inner.length > 0 && (\n <EllipseSet items={ringShapes.inner} role=\"model\" hoveredId={hoverOf(\"ring\")} selectedIds={selected.ring} dimmed={isDimmed} />\n )}\n <PointSet\n items={ringPoints}\n kind=\"plus\"\n markers={TARGET_MARKERS}\n labels={showLabels}\n hoveredId={hoverOf(\"ring\")}\n selectedIds={selected.ring}\n dimmed={isDimmed}\n onHoverChange={hoverFrom(\"ring\")}\n onItemPress={pressFrom(\"ring\")}\n layerId={layerId(\"rings\")}\n label=\"Rings\"\n />\n </>\n )}\n {hasCorners && (\n <GridLayer\n nodes={nodes}\n markers={TARGET_MARKERS}\n edges={{ i: edgeStyle, j: { ...edgeStyle, dashed: true } }}\n labels={showLabels}\n hoveredId={hoverOf(\"corner\")}\n selectedIds={selected.corner}\n dimmed={isDimmed}\n onHoverChange={hoverFrom(\"corner\")}\n onItemPress={pressFrom(\"corner\")}\n layerId={layerId(\"corners\")}\n label=\"Corners\"\n />\n )}\n {hasCircles && (\n <PointSet\n items={circles}\n markers={TARGET_MARKERS}\n labels={showLabels}\n hoveredId={hoverOf(\"circle\")}\n selectedIds={selected.circle}\n dimmed={isDimmed}\n onHoverChange={hoverFrom(\"circle\")}\n onItemPress={pressFrom(\"circle\")}\n layerId={layerId(\"circles\")}\n label=\"Circles\"\n />\n )}\n </>\n );\n}\n","/**\n * PuzzleBoard edge bits: from a decoder's observed edges to the dots the overlay draws.\n *\n * A PuzzleBoard encodes its position in the bumps along the edges between corners. The decoder\n * reports each observed edge in the image's own local frame (`row`, `col`), and the alignment\n * that maps that frame into the board's master frame, which is periodic with period 501. The\n * corners are labelled with master indices, so an edge's two corners are found by mapping its\n * local end points through the alignment, modulo the period. This is the arithmetic of\n * vitavision's `PuzzleboardOverlay.buildEdgeMarkers`, as a pure function over structural types,\n * so no detector package is imported.\n *\n * Pure: no React, no DOM.\n */\n\nimport { gridKey } from \"./lattice\";\nimport type { TargetCorner, TargetEdgeBit } from \"./model\";\n\n/** The period of the PuzzleBoard master pattern. */\nexport const PUZZLEBOARD_PERIOD = 501;\n\n/** One observed edge of a PuzzleBoard decode. */\nexport interface PuzzleboardEdge {\n /** Row of the edge's first corner, in the image's local frame. */\n row: number;\n /** Column of the edge's first corner, in the image's local frame. */\n col: number;\n /** `\"horizontal\"` joins local `(col, row)` to `(col + 1, row)`; `\"vertical\"` to `(col, row + 1)`. */\n orientation: \"horizontal\" | \"vertical\";\n /** The decoded bit. */\n bit: 0 | 1;\n /** Decode confidence, [0, 1]. */\n confidence: number;\n}\n\n/** The map from the local frame to master indices: `master = M · local + translation`, modulo the period. */\nexport interface PuzzleboardAlignment {\n /** The 2×2 integer matrix `[[a, b], [c, d]]`, acting on local `(i, j)`. */\n transform: { a: number; b: number; c: number; d: number };\n /** The translation, added after the matrix. */\n translation: readonly [number, number];\n}\n\n/** `value` modulo `period`, in `[0, period)` for any sign. */\nfunction wrap(value: number, period: number): number {\n return ((value % period) + period) % period;\n}\n\n/**\n * The edge bits of a PuzzleBoard decode, placed on the image.\n *\n * An edge is dropped when either of its corners was not detected. Each dot sits at the midpoint\n * of its edge with a radius of a quarter of the edge's length (the bump is about half an edge\n * wide); its opacity is the app's to take from `confidence`.\n *\n * @param edges - The observed edges.\n * @param corners - The labelled corners, whose `i` and `j` are **master** indices.\n * @param alignment - The local-to-master map.\n * @param period - The master pattern's period. Defaults to 501.\n * @returns One `TargetEdgeBit` per edge whose corners were both found, in input order. Empty when there is no alignment.\n */\nexport function edgeBitsFromPuzzleboard(\n edges: readonly PuzzleboardEdge[],\n corners: readonly TargetCorner[],\n alignment: PuzzleboardAlignment | null | undefined,\n period: number = PUZZLEBOARD_PERIOD,\n): TargetEdgeBit[] {\n if (!alignment || edges.length === 0 || corners.length === 0) return [];\n\n const byMaster = new Map<string, TargetCorner>();\n for (const corner of corners) {\n if (Number.isInteger(corner.i) && Number.isInteger(corner.j)) byMaster.set(gridKey(corner.i!, corner.j!), corner);\n }\n const { a, b, c, d } = alignment.transform;\n const [tx, ty] = alignment.translation;\n const toMaster = (i: number, j: number): string => gridKey(wrap(a * i + b * j + tx, period), wrap(c * i + d * j + ty, period));\n\n const out: TargetEdgeBit[] = [];\n edges.forEach((edge, index) => {\n // Local coordinates are (i = col, j = row).\n const from = byMaster.get(toMaster(edge.col, edge.row));\n const to = byMaster.get(edge.orientation === \"horizontal\" ? toMaster(edge.col + 1, edge.row) : toMaster(edge.col, edge.row + 1));\n if (!from || !to) return;\n out.push({\n id: `${edge.orientation}-${edge.row}-${edge.col}-${index}`,\n x: 0.5 * (from.x + to.x),\n y: 0.5 * (from.y + to.y),\n radius: 0.25 * Math.hypot(to.x - from.x, to.y - from.y),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I,KAAK,CAAC;GACtD,KAAK,KAAK;GACV,YAAY,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,KAAK,UAAU,CAAC;EACtD,CAAC;CACH,CAAC;CACD,OAAO;AACT"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitavision/overlays",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Calibration-target overlays for the vitavision lab apps: one TargetOverlay for chessboard, ChArUco, marker board, PuzzleBoard and ring-grid detections on the stage2d image stage.",
|
|
5
5
|
"license": "MIT OR Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@storybook/react-vite": "10.6.0",
|
|
51
|
-
"@vitavision/stage2d": "
|
|
52
|
-
"@vitavision/ui": "
|
|
51
|
+
"@vitavision/stage2d": "^0.10.0",
|
|
52
|
+
"@vitavision/ui": "^0.11.0",
|
|
53
53
|
"storybook": "10.6.0"
|
|
54
54
|
}
|
|
55
55
|
}
|