@kubohiroya/turbowarp-camera-calibration 0.8.2 → 0.10.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.ja.md CHANGED
@@ -101,7 +101,7 @@ bundleは約11 MBあります。
101
101
  検証済みのversionをexact pinします。
102
102
 
103
103
  ```bash
104
- pnpm add --save-exact @kubohiroya/turbowarp-camera-calibration@0.8.2
104
+ pnpm add --save-exact @kubohiroya/turbowarp-camera-calibration@0.10.0
105
105
  ```
106
106
 
107
107
  standalone bundle:
@@ -113,7 +113,7 @@ node_modules/@kubohiroya/turbowarp-camera-calibration/dist/camera-calibration.js
113
113
  version固定CDN URL:
114
114
 
115
115
  ```text
116
- https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-camera-calibration@0.8.2/dist/camera-calibration.js
116
+ https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-camera-calibration@0.10.0/dist/camera-calibration.js
117
117
  ```
118
118
 
119
119
  ## クイックスタート
package/README.md CHANGED
@@ -102,7 +102,7 @@ therefore about 11 MB.
102
102
  Install an exact version that you have reviewed:
103
103
 
104
104
  ```bash
105
- pnpm add --save-exact @kubohiroya/turbowarp-camera-calibration@0.8.2
105
+ pnpm add --save-exact @kubohiroya/turbowarp-camera-calibration@0.10.0
106
106
  ```
107
107
 
108
108
  Load the standalone bundle from:
@@ -114,7 +114,7 @@ node_modules/@kubohiroya/turbowarp-camera-calibration/dist/camera-calibration.js
114
114
  A version-pinned CDN URL is:
115
115
 
116
116
  ```text
117
- https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-camera-calibration@0.8.2/dist/camera-calibration.js
117
+ https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-camera-calibration@0.10.0/dist/camera-calibration.js
118
118
  ```
119
119
 
120
120
  ## Quick start
@@ -248,6 +248,36 @@ Returns what the operator should do next while automatic capture runs: show-the-
248
248
  | Opcode | `cameraCalibrationGuidance` |
249
249
  | `CAMERA_ID` | String, default: `default` |
250
250
 
251
+ ### `camera calibration novelty [CAMERA_ID]`
252
+
253
+ Returns how much the view automatic capture is looking at would add, from 0 to 1. One is a view turned as far from every retained view as the whole set is required to spread; zero means nothing usable is in frame. Measured in tilt, not in where the corners landed: sliding the board moves every corner and adds nothing a solve can use. Meant to drive something continuous -- a tone, a bar, a click rate -- because the operator is holding the board and not reading the screen.
254
+
255
+ | Property | Value |
256
+ |---|---|
257
+ | Type | Reporter |
258
+ | Opcode | `cameraCalibrationNovelty` |
259
+ | `CAMERA_ID` | String, default: `default` |
260
+
261
+ ### `camera calibration tilt direction [CAMERA_ID]`
262
+
263
+ Returns which way the board still has to be turned: top-near, top-far, left-near, right-near, or empty outside a live session. The direction least represented in what has been collected, so that "tilt it more" -- an instruction the operator has to interpret -- becomes one they can carry out.
264
+
265
+ | Property | Value |
266
+ |---|---|
267
+ | Type | Reporter |
268
+ | Opcode | `cameraCalibrationTiltDirection` |
269
+ | `CAMERA_ID` | String, default: `default` |
270
+
271
+ ### `camera calibration progress [CAMERA_ID]`
272
+
273
+ Returns how far the session has come, from 0 to 16. Four gates of four steps: enough views to solve from, enough tilt among them, enough views to hold some back, and the answer holding up on the views it was not fitted to. Counted in order and stopped at the first unfinished gate, so the number says which gate is being worked on as well as how far into it. Never falls. Sixteen because that is enough to sound like progress and few enough to hear as distinct.
274
+
275
+ | Property | Value |
276
+ |---|---|
277
+ | Type | Reporter |
278
+ | Opcode | `cameraCalibrationProgress` |
279
+ | `CAMERA_ID` | String, default: `default` |
280
+
251
281
  ### `solve calibration for camera [CAMERA_ID]`
252
282
 
253
283
  Solves the intrinsic matrix and distortion coefficients from at least eight accepted samples, then releases the camera lease. No external pose is produced.
@@ -108,6 +108,36 @@
108
108
  "defaultValue": "default"
109
109
  } }
110
110
  },
111
+ {
112
+ "opcode": "cameraCalibrationNovelty",
113
+ "blockType": "REPORTER",
114
+ "text": "camera calibration novelty [CAMERA_ID]",
115
+ "description": "Returns how much the view automatic capture is looking at would add, from 0 to 1. One is a view turned as far from every retained view as the whole set is required to spread; zero means nothing usable is in frame. Measured in tilt, not in where the corners landed: sliding the board moves every corner and adds nothing a solve can use. Meant to drive something continuous -- a tone, a bar, a click rate -- because the operator is holding the board and not reading the screen.",
116
+ "arguments": { "CAMERA_ID": {
117
+ "type": "STRING",
118
+ "defaultValue": "default"
119
+ } }
120
+ },
121
+ {
122
+ "opcode": "cameraCalibrationTiltDirection",
123
+ "blockType": "REPORTER",
124
+ "text": "camera calibration tilt direction [CAMERA_ID]",
125
+ "description": "Returns which way the board still has to be turned: top-near, top-far, left-near, right-near, or empty outside a live session. The direction least represented in what has been collected, so that \"tilt it more\" -- an instruction the operator has to interpret -- becomes one they can carry out.",
126
+ "arguments": { "CAMERA_ID": {
127
+ "type": "STRING",
128
+ "defaultValue": "default"
129
+ } }
130
+ },
131
+ {
132
+ "opcode": "cameraCalibrationProgress",
133
+ "blockType": "REPORTER",
134
+ "text": "camera calibration progress [CAMERA_ID]",
135
+ "description": "Returns how far the session has come, from 0 to 16. Four gates of four steps: enough views to solve from, enough tilt among them, enough views to hold some back, and the answer holding up on the views it was not fitted to. Counted in order and stopped at the first unfinished gate, so the number says which gate is being worked on as well as how far into it. Never falls. Sixteen because that is enough to sound like progress and few enough to hear as distinct.",
136
+ "arguments": { "CAMERA_ID": {
137
+ "type": "STRING",
138
+ "defaultValue": "default"
139
+ } }
140
+ },
111
141
  {
112
142
  "opcode": "solveCameraCalibration",
113
143
  "blockType": "COMMAND",
@@ -735,6 +765,44 @@
735
765
  y: 0
736
766
  });
737
767
  /**
768
+ * Which way the board still has to be turned.
769
+ *
770
+ * `x` is the upper half's grid steps against the lower half's, so a positive
771
+ * `x` is a board whose top is nearer the camera. `y` is the left half against
772
+ * the right, so a positive `y` is a board whose left edge is nearer. The names
773
+ * are in the contract; the signs they correspond to are here.
774
+ */
775
+ /**
776
+ * The direction least represented in what has been collected.
777
+ *
778
+ * Each direction is scored by the furthest any held view reaches along it, and
779
+ * the weakest wins. Asking for the weakest rather than simply "more tilt"
780
+ * turns an instruction the operator has to interpret into one they can carry
781
+ * out, and it spreads the set on purpose rather than by luck.
782
+ *
783
+ * Nothing collected asks for the first direction rather than nothing at all:
784
+ * an operator holding a board square-on has to be told to start somewhere.
785
+ */
786
+ function weakestTiltDirection(samples, board) {
787
+ const tilts = samples.map((sample) => tiltOf(sample, board));
788
+ const reach = [
789
+ ["top-near", (tilt) => tilt.x],
790
+ ["top-far", (tilt) => -tilt.x],
791
+ ["left-near", (tilt) => tilt.y],
792
+ ["right-near", (tilt) => -tilt.y]
793
+ ];
794
+ let weakest = "top-near";
795
+ let smallest = Number.POSITIVE_INFINITY;
796
+ for (const [direction, along] of reach) {
797
+ const furthest = tilts.reduce((best, tilt) => Math.max(best, along(tilt)), 0);
798
+ if (furthest < smallest) {
799
+ smallest = furthest;
800
+ weakest = direction;
801
+ }
802
+ }
803
+ return weakest;
804
+ }
805
+ /**
738
806
  * The minimum spread of tilts a solve is allowed to proceed from.
739
807
  *
740
808
  * A board half as wide as its distance, tilted thirty degrees, gives an edge
@@ -743,6 +811,16 @@
743
811
  * way every time, without refusing a cautious operator who varied it a little.
744
812
  */
745
813
  var MINIMUM_POSE_SPREAD = .08;
814
+ /**
815
+ * How differently two views were turned.
816
+ *
817
+ * The distance the solve cares about. Two views taken from the same angle
818
+ * constrain the same thing however far apart on the board they were taken, so
819
+ * this ignores where the board was and reads only how it was turned.
820
+ */
821
+ function tiltDistance(left, right) {
822
+ return Math.hypot(left.x - right.x, left.y - right.y);
823
+ }
746
824
  function tiltOf(sample, board) {
747
825
  const { columns, rows } = board;
748
826
  const at = /* @__PURE__ */ new Map();
@@ -893,6 +971,8 @@
893
971
  this.operation = 0;
894
972
  this.automatic = false;
895
973
  this.guidanceCode = "";
974
+ this.noveltyNow = 0;
975
+ this.progressReached = 0;
896
976
  this.solvedFrom = 0;
897
977
  }
898
978
  async start(options) {
@@ -951,6 +1031,7 @@
951
1031
  this.lease = lease;
952
1032
  this.samples = [];
953
1033
  this.solvedFrom = 0;
1034
+ this.progressReached = 0;
954
1035
  this.sessionSampleCount = 0;
955
1036
  this.sampleQuality = 0;
956
1037
  this.reprojectionError = 0;
@@ -996,6 +1077,42 @@
996
1077
  guidance() {
997
1078
  return this.guidanceCode;
998
1079
  }
1080
+ novelty() {
1081
+ return this.noveltyNow;
1082
+ }
1083
+ /**
1084
+ * How far the session has come, in steps of the sixteen.
1085
+ *
1086
+ * Counted gate by gate in the order they have to be passed, stopping at the
1087
+ * first one not finished -- so the number says which gate is being worked on
1088
+ * as well as how far into it. Held at its highest: a set's spread can fall
1089
+ * when a view is replaced, and a count that went backwards would tell the
1090
+ * operator they had broken something they had not.
1091
+ */
1092
+ progress() {
1093
+ if (this.calibrationState === "solved") return 16;
1094
+ const session = this.session;
1095
+ if (!session) return this.progressReached;
1096
+ const shares = [
1097
+ this.samples.length / MINIMUM_SAMPLES,
1098
+ poseSpread(this.samples, session.board) / MINIMUM_POSE_SPREAD,
1099
+ (this.samples.length - MINIMUM_SAMPLES) / 4,
1100
+ this.holdoutCount > 0 && this.holdoutError > 0 ? session.maximumReprojectionErrorPx / this.holdoutError : 0
1101
+ ];
1102
+ let steps = 0;
1103
+ for (const share of shares) {
1104
+ const passed = Math.max(0, Math.min(4, Math.floor(share * 4)));
1105
+ steps += passed;
1106
+ if (passed < 4) break;
1107
+ }
1108
+ this.progressReached = Math.max(this.progressReached, steps);
1109
+ return this.progressReached;
1110
+ }
1111
+ /** Which way to turn the board next. Empty outside a live session. */
1112
+ tiltDirection() {
1113
+ if (!this.session || !this.lease) return "";
1114
+ return weakestTiltDirection(this.samples, this.session.board);
1115
+ }
999
1116
  /**
1000
1117
  * Waits for the camera to hand over a frame with a size on it.
1001
1118
  *
@@ -1022,6 +1139,7 @@
1022
1139
  }
1023
1140
  stopAutomatic() {
1024
1141
  this.automatic = false;
1142
+ this.noveltyNow = 0;
1025
1143
  this.cancelTick?.();
1026
1144
  this.cancelTick = void 0;
1027
1145
  }
@@ -1339,6 +1457,7 @@
1339
1457
  if (operation !== this.operation) return;
1340
1458
  const sample = detection.sample;
1341
1459
  if (!sample) {
1460
+ this.noveltyNow = 0;
1342
1461
  const elsewhere = detection.markersSeen > 0;
1343
1462
  if (automatic) return this.decline(elsewhere ? "wrong-board" : "show-the-board");
1344
1463
  if (elsewhere) this.reject("wrong-board", `${detection.markersSeen} markers are in frame and they do not make the ${session.board.columns}x${session.board.rows} board. Show that board, or start again with the one you are holding.`);
@@ -1349,6 +1468,7 @@
1349
1468
  this.reject("sample-low-quality", `Sample quality must be at least ${MINIMUM_SAMPLE_QUALITY}.`);
1350
1469
  }
1351
1470
  const accepted = sample;
1471
+ this.noveltyNow = this.noveltyOf(accepted, session);
1352
1472
  if (this.samples.some((previous) => normalizedCornerDistance(previous, accepted, session.imageWidth, session.imageHeight) < MINIMUM_NORMALIZED_NOVELTY)) {
1353
1473
  if (automatic) return this.decline("move-or-tilt");
1354
1474
  this.reject("sample-too-similar", "Move or tilt the board before capturing another sample.");
@@ -1393,6 +1513,27 @@
1393
1513
  }
1394
1514
  this.samples.splice(dullest, 1);
1395
1515
  }
1516
+ /**
1517
+ * How much the view being looked at would add, from 0 to 1.
1518
+ *
1519
+ * Measured in tilt, not in where the corners landed. The corner distance is
1520
+ * what decides whether a view is a duplicate, and it is deliberately not
1521
+ * this: sliding the board across the frame moves every corner a long way and
1522
+ * adds nothing a solve can use, so a signal driven by it would be loudest
1523
+ * for the one motion that does not work. Tilt is what separates focal length
1524
+ * from distance, so tilt is what this rewards.
1525
+ *
1526
+ * One is a view turned as far from everything held as the whole set is
1527
+ * required to spread, which is a view worth stopping for. An empty set reads
1528
+ * as one, because the first view is the most useful one there is.
1529
+ */
1530
+ noveltyOf(sample, session) {
1531
+ if (this.samples.length === 0) return 1;
1532
+ const tilt = tiltOf(sample, session.board);
1533
+ let nearest = Number.POSITIVE_INFINITY;
1534
+ for (const held of this.samples) nearest = Math.min(nearest, tiltDistance(tilt, tiltOf(held, session.board)));
1535
+ return Math.max(0, Math.min(1, nearest / MINIMUM_POSE_SPREAD));
1536
+ }
1396
1537
  /** Records what the operator should do next, without disturbing the state. */
1397
1538
  guide(guidance) {
1398
1539
  this.guidanceCode = guidance;
@@ -1557,6 +1698,15 @@
1557
1698
  guidance(cameraId) {
1558
1699
  return this.existing(cameraId)?.guidance() ?? "";
1559
1700
  }
1701
+ novelty(cameraId) {
1702
+ return this.existing(cameraId)?.novelty() ?? 0;
1703
+ }
1704
+ tiltDirection(cameraId) {
1705
+ return this.existing(cameraId)?.tiltDirection() ?? "";
1706
+ }
1707
+ progress(cameraId) {
1708
+ return this.existing(cameraId)?.progress() ?? 0;
1709
+ }
1560
1710
  cancel(cameraId) {
1561
1711
  return this.existing(cameraId)?.cancel() ?? Promise.resolve();
1562
1712
  }
@@ -2100,9 +2250,9 @@
2100
2250
  var runtimeCapabilityKey = "kubohiroyaCameraCalibrationCapability";
2101
2251
  function createRuntimeCapability(host) {
2102
2252
  const capability = {
2103
- version: 2,
2253
+ version: 4,
2104
2254
  requireVersion(version) {
2105
- if (!Number.isInteger(version) || version < 1 || version > 2) throw new Error(`Unsupported Camera Calibration runtime capability version: ${version}; this build provides 2.`);
2255
+ if (!Number.isInteger(version) || version < 1 || version > 4) throw new Error(`Unsupported Camera Calibration runtime capability version: ${version}; this build provides 4.`);
2106
2256
  return capability;
2107
2257
  },
2108
2258
  start: (options) => host.start(options),
@@ -2110,6 +2260,9 @@
2110
2260
  setAutomatic: (cameraId, enabled) => host.setAutomatic(cameraId, enabled),
2111
2261
  automatic: (cameraId) => host.automatic(cameraId),
2112
2262
  guidance: (cameraId) => host.guidance(cameraId),
2263
+ novelty: (cameraId) => host.novelty(cameraId),
2264
+ tiltDirection: (cameraId) => host.tiltDirection(cameraId),
2265
+ progress: (cameraId) => host.progress(cameraId),
2113
2266
  solve: (cameraId) => host.solve(cameraId),
2114
2267
  publish: (cameraId) => host.publish(cameraId),
2115
2268
  cancel: (cameraId) => host.cancel(cameraId),
@@ -2211,6 +2364,15 @@
2211
2364
  cameraCalibrationGuidance(args) {
2212
2365
  return this.controller.guidance(normalizeId(args.CAMERA_ID));
2213
2366
  }
2367
+ cameraCalibrationNovelty(args) {
2368
+ return this.controller.novelty(normalizeId(args.CAMERA_ID));
2369
+ }
2370
+ cameraCalibrationTiltDirection(args) {
2371
+ return this.controller.tiltDirection(normalizeId(args.CAMERA_ID));
2372
+ }
2373
+ cameraCalibrationProgress(args) {
2374
+ return this.controller.progress(normalizeId(args.CAMERA_ID));
2375
+ }
2214
2376
  async solveCameraCalibration(args) {
2215
2377
  await this.controller.solve(normalizeId(args.CAMERA_ID));
2216
2378
  }
@@ -2297,6 +2459,9 @@
2297
2459
  setAutomatic: (cameraId, enabled) => this.controller.setAutomatic(normalizeId(cameraId), enabled),
2298
2460
  automatic: (cameraId) => this.controller.automatic(normalizeId(cameraId)),
2299
2461
  guidance: (cameraId) => this.controller.guidance(normalizeId(cameraId)),
2462
+ novelty: (cameraId) => this.controller.novelty(normalizeId(cameraId)),
2463
+ tiltDirection: (cameraId) => this.controller.tiltDirection(normalizeId(cameraId)),
2464
+ progress: (cameraId) => this.controller.progress(normalizeId(cameraId)),
2300
2465
  solve: (cameraId) => this.controller.solve(normalizeId(cameraId)),
2301
2466
  publish: (cameraId) => this.controller.publishProfile(normalizeId(cameraId)),
2302
2467
  cancel: (cameraId) => this.controller.cancel(normalizeId(cameraId)),
@@ -111,6 +111,16 @@
111
111
  }
112
112
  ]
113
113
  },
114
+ {
115
+ "opcode": "cameraCalibrationNovelty",
116
+ "blockType": "REPORTER",
117
+ "arguments": [
118
+ {
119
+ "id": "CAMERA_ID",
120
+ "type": "STRING"
121
+ }
122
+ ]
123
+ },
114
124
  {
115
125
  "opcode": "cameraCalibrationPoseSpread",
116
126
  "blockType": "REPORTER",
@@ -121,6 +131,16 @@
121
131
  }
122
132
  ]
123
133
  },
134
+ {
135
+ "opcode": "cameraCalibrationProgress",
136
+ "blockType": "REPORTER",
137
+ "arguments": [
138
+ {
139
+ "id": "CAMERA_ID",
140
+ "type": "STRING"
141
+ }
142
+ ]
143
+ },
124
144
  {
125
145
  "opcode": "cameraCalibrationReady",
126
146
  "blockType": "BOOLEAN",
@@ -171,6 +191,16 @@
171
191
  }
172
192
  ]
173
193
  },
194
+ {
195
+ "opcode": "cameraCalibrationTiltDirection",
196
+ "blockType": "REPORTER",
197
+ "arguments": [
198
+ {
199
+ "id": "CAMERA_ID",
200
+ "type": "STRING"
201
+ }
202
+ ]
203
+ },
174
204
  {
175
205
  "opcode": "cancelCameraCalibration",
176
206
  "blockType": "COMMAND",
@@ -60,6 +60,43 @@ export type CalibrationGuidance = ''
60
60
  | 'solving'
61
61
  /** Solved and validated. Nothing further is needed. */
62
62
  | 'complete';
63
+ /**
64
+ * How far a session has come, counted in sixteen steps.
65
+ *
66
+ * Four gates of four steps, in the order they have to be passed. A gate is
67
+ * what actually stops the session finishing, so this is not a guess at how
68
+ * long is left: it is how much of what is required has been done.
69
+ *
70
+ * | steps | gate | done when |
71
+ * |---|---|---|
72
+ * | 0-3 | enough views to solve from at all | the minimum sample count |
73
+ * | 4-7 | enough tilt to solve from | the minimum pose spread |
74
+ * | 8-11 | enough views to hold some back | the automatic completion count |
75
+ * | 12-15 | the answer holding up on the views it was not fitted to | the hold-out error under the limit |
76
+ * | 16 | solved | -- |
77
+ *
78
+ * Counted in order and stopped at the first unfinished gate, so the step
79
+ * number says which gate is being worked on as well as how far into it. And
80
+ * never decreasing: the spread of a set can fall when a view is replaced, and
81
+ * an operator hearing the count go backwards would reasonably think they had
82
+ * broken something.
83
+ */
84
+ export declare const CALIBRATION_GATES = 4;
85
+ export declare const CALIBRATION_STEPS_PER_GATE = 4;
86
+ export declare const CALIBRATION_PROGRESS_STEPS: number;
87
+ /**
88
+ * Which way the board still has to be turned.
89
+ *
90
+ * Two axes, one sign at a time. `top-near` and `top-far` turn it about the
91
+ * horizontal axis; `left-near` and `right-near` about the vertical one. That
92
+ * is as much as can be said without knowing where the operator is standing,
93
+ * and as much as they need, since they are looking at the same board.
94
+ *
95
+ * Here rather than beside the arithmetic that works it out, because the
96
+ * published entry carries declarations and nothing else: a consumer asking
97
+ * what the names mean must not pull in the measuring.
98
+ */
99
+ export type TiltDirection = '' | 'top-near' | 'top-far' | 'left-near' | 'right-near';
63
100
  /**
64
101
  * Where the scale of a measured pose came from.
65
102
  *
@@ -1 +1,24 @@
1
- export {};
1
+ /**
2
+ * How far a session has come, counted in sixteen steps.
3
+ *
4
+ * Four gates of four steps, in the order they have to be passed. A gate is
5
+ * what actually stops the session finishing, so this is not a guess at how
6
+ * long is left: it is how much of what is required has been done.
7
+ *
8
+ * | steps | gate | done when |
9
+ * |---|---|---|
10
+ * | 0-3 | enough views to solve from at all | the minimum sample count |
11
+ * | 4-7 | enough tilt to solve from | the minimum pose spread |
12
+ * | 8-11 | enough views to hold some back | the automatic completion count |
13
+ * | 12-15 | the answer holding up on the views it was not fitted to | the hold-out error under the limit |
14
+ * | 16 | solved | -- |
15
+ *
16
+ * Counted in order and stopped at the first unfinished gate, so the step
17
+ * number says which gate is being worked on as well as how far into it. And
18
+ * never decreasing: the spread of a set can fall when a view is replaced, and
19
+ * an operator hearing the count go backwards would reasonably think they had
20
+ * broken something.
21
+ */
22
+ export const CALIBRATION_GATES = 4;
23
+ export const CALIBRATION_STEPS_PER_GATE = 4;
24
+ export const CALIBRATION_PROGRESS_STEPS = CALIBRATION_GATES * CALIBRATION_STEPS_PER_GATE;
@@ -12,9 +12,9 @@
12
12
  * finding a method missing partway through a calibration the operator is
13
13
  * already standing in front of.
14
14
  */
15
- import type { BoardPoseOptions, CalibrationErrorCode, CalibrationGuidance, CalibrationStartOptions, CalibrationState } from './calibration/contract.js';
15
+ import type { BoardPoseOptions, CalibrationErrorCode, CalibrationGuidance, CalibrationStartOptions, CalibrationState, TiltDirection } from './calibration/contract.js';
16
16
  export declare const runtimeCapabilityKey = "kubohiroyaCameraCalibrationCapability";
17
- export declare const runtimeCapabilityVersion: 2;
17
+ export declare const runtimeCapabilityVersion: 4;
18
18
  export interface CameraCalibrationCapabilityV1 {
19
19
  readonly version: typeof runtimeCapabilityVersion;
20
20
  requireVersion(version: number): CameraCalibrationCapabilityV1;
@@ -49,6 +49,40 @@ export interface CameraCalibrationCapabilityV1 {
49
49
  * recording those as errors would leave one showing for most of a session.
50
50
  */
51
51
  guidance(cameraId: string): CalibrationGuidance;
52
+ /**
53
+ * How much the view the shutter is looking at would add, 0 to 1. Since v3.
54
+ *
55
+ * Measured in tilt rather than in where the corners landed: sliding the
56
+ * board moves every corner and adds nothing a solve can use, so a signal
57
+ * driven by corner distance would be loudest for the one motion that does
58
+ * not work. One is a view turned as far from everything held as the whole
59
+ * set is required to spread. Zero when nothing usable is in frame.
60
+ *
61
+ * Meant for something continuous -- a tone, a bar, a click rate -- because
62
+ * the operator is holding the board and not reading the screen.
63
+ */
64
+ novelty(cameraId: string): number;
65
+ /**
66
+ * Which way the board still has to be turned. Since v3.
67
+ *
68
+ * `top-near`, `top-far`, `left-near`, `right-near`, or empty outside a live
69
+ * session. The direction least represented in what has been collected, so
70
+ * that "tilt it more" -- an instruction the operator has to interpret --
71
+ * becomes one they can carry out.
72
+ */
73
+ tiltDirection(cameraId: string): TiltDirection;
74
+ /**
75
+ * How far the session has come, 0 to 16. Since v4.
76
+ *
77
+ * Four gates of four steps, counted in the order they have to be passed and
78
+ * stopped at the first unfinished one -- so the number says which gate is
79
+ * being worked on as well as how far into it. Never falls.
80
+ *
81
+ * For telling the operator where they are without their reading anything:
82
+ * sixteen steps is enough to sound like progress and few enough to be heard
83
+ * as distinct. `CALIBRATION_PROGRESS_STEPS` names the total.
84
+ */
85
+ progress(cameraId: string): number;
52
86
  /** Solves from the accepted samples and releases the camera. */
53
87
  solve(cameraId: string): Promise<void>;
54
88
  /** Hands the solved profile to Camera Source, which owns the profile contract. */
@@ -1,5 +1,5 @@
1
1
  export const runtimeCapabilityKey = 'kubohiroyaCameraCalibrationCapability';
2
- export const runtimeCapabilityVersion = 2;
2
+ export const runtimeCapabilityVersion = 4;
3
3
  export function createRuntimeCapability(host) {
4
4
  const capability = {
5
5
  version: runtimeCapabilityVersion,
@@ -20,6 +20,9 @@ export function createRuntimeCapability(host) {
20
20
  setAutomatic: (cameraId, enabled) => host.setAutomatic(cameraId, enabled),
21
21
  automatic: (cameraId) => host.automatic(cameraId),
22
22
  guidance: (cameraId) => host.guidance(cameraId),
23
+ novelty: (cameraId) => host.novelty(cameraId),
24
+ tiltDirection: (cameraId) => host.tiltDirection(cameraId),
25
+ progress: (cameraId) => host.progress(cameraId),
23
26
  solve: (cameraId) => host.solve(cameraId),
24
27
  publish: (cameraId) => host.publish(cameraId),
25
28
  cancel: (cameraId) => host.cancel(cameraId),
package/lib/runtime.d.ts CHANGED
@@ -15,7 +15,8 @@
15
15
  * every attempt to publish a profile failed with a version mismatch that had
16
16
  * nothing to do with versions.
17
17
  */
18
- export type { CalibrationErrorCode, CalibrationGuidance, CalibrationStartOptions, CalibrationState } from './calibration/contract.js';
18
+ export { CALIBRATION_GATES, CALIBRATION_PROGRESS_STEPS, CALIBRATION_STEPS_PER_GATE } from './calibration/contract.js';
19
+ export type { CalibrationErrorCode, CalibrationGuidance, CalibrationStartOptions, CalibrationState, TiltDirection } from './calibration/contract.js';
19
20
  export type { CalibrationBoard } from './calibration/types.js';
20
21
  export { createRuntimeCapability, runtimeCapabilityKey, runtimeCapabilityVersion, type CameraCalibrationCapabilityV1 } from './runtime-capability.js';
21
22
  import { type CameraCalibrationCapabilityV1 } from './runtime-capability.js';
package/lib/runtime.js CHANGED
@@ -15,6 +15,7 @@
15
15
  * every attempt to publish a profile failed with a version mismatch that had
16
16
  * nothing to do with versions.
17
17
  */
18
+ export { CALIBRATION_GATES, CALIBRATION_PROGRESS_STEPS, CALIBRATION_STEPS_PER_GATE } from './calibration/contract.js';
18
19
  export { createRuntimeCapability, runtimeCapabilityKey, runtimeCapabilityVersion } from './runtime-capability.js';
19
20
  import { runtimeCapabilityKey } from './runtime-capability.js';
20
21
  /** The extension ID, as it appears in opcodes and in a project's extension list. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubohiroya/turbowarp-camera-calibration",
3
- "version": "0.8.2",
3
+ "version": "0.10.0",
4
4
  "description": "A TurboWarp extension that calibrates a shared Camera Source camera and publishes its intrinsic calibration profile.",
5
5
  "author": "Hiroya Kubo <hiroya@cuc.ac.jp>",
6
6
  "license": "MPL-2.0",
@@ -97,6 +97,42 @@
97
97
  }
98
98
  }
99
99
  },
100
+ {
101
+ "opcode": "cameraCalibrationNovelty",
102
+ "blockType": "REPORTER",
103
+ "text": "camera calibration novelty [CAMERA_ID]",
104
+ "description": "Returns how much the view automatic capture is looking at would add, from 0 to 1. One is a view turned as far from every retained view as the whole set is required to spread; zero means nothing usable is in frame. Measured in tilt, not in where the corners landed: sliding the board moves every corner and adds nothing a solve can use. Meant to drive something continuous -- a tone, a bar, a click rate -- because the operator is holding the board and not reading the screen.",
105
+ "arguments": {
106
+ "CAMERA_ID": {
107
+ "type": "STRING",
108
+ "defaultValue": "default"
109
+ }
110
+ }
111
+ },
112
+ {
113
+ "opcode": "cameraCalibrationTiltDirection",
114
+ "blockType": "REPORTER",
115
+ "text": "camera calibration tilt direction [CAMERA_ID]",
116
+ "description": "Returns which way the board still has to be turned: top-near, top-far, left-near, right-near, or empty outside a live session. The direction least represented in what has been collected, so that \"tilt it more\" -- an instruction the operator has to interpret -- becomes one they can carry out.",
117
+ "arguments": {
118
+ "CAMERA_ID": {
119
+ "type": "STRING",
120
+ "defaultValue": "default"
121
+ }
122
+ }
123
+ },
124
+ {
125
+ "opcode": "cameraCalibrationProgress",
126
+ "blockType": "REPORTER",
127
+ "text": "camera calibration progress [CAMERA_ID]",
128
+ "description": "Returns how far the session has come, from 0 to 16. Four gates of four steps: enough views to solve from, enough tilt among them, enough views to hold some back, and the answer holding up on the views it was not fitted to. Counted in order and stopped at the first unfinished gate, so the number says which gate is being worked on as well as how far into it. Never falls. Sixteen because that is enough to sound like progress and few enough to hear as distinct.",
129
+ "arguments": {
130
+ "CAMERA_ID": {
131
+ "type": "STRING",
132
+ "defaultValue": "default"
133
+ }
134
+ }
135
+ },
100
136
  {
101
137
  "opcode": "solveCameraCalibration",
102
138
  "blockType": "COMMAND",
@@ -97,6 +97,45 @@ export type CalibrationGuidance =
97
97
  /** Solved and validated. Nothing further is needed. */
98
98
  | 'complete';
99
99
 
100
+ /**
101
+ * How far a session has come, counted in sixteen steps.
102
+ *
103
+ * Four gates of four steps, in the order they have to be passed. A gate is
104
+ * what actually stops the session finishing, so this is not a guess at how
105
+ * long is left: it is how much of what is required has been done.
106
+ *
107
+ * | steps | gate | done when |
108
+ * |---|---|---|
109
+ * | 0-3 | enough views to solve from at all | the minimum sample count |
110
+ * | 4-7 | enough tilt to solve from | the minimum pose spread |
111
+ * | 8-11 | enough views to hold some back | the automatic completion count |
112
+ * | 12-15 | the answer holding up on the views it was not fitted to | the hold-out error under the limit |
113
+ * | 16 | solved | -- |
114
+ *
115
+ * Counted in order and stopped at the first unfinished gate, so the step
116
+ * number says which gate is being worked on as well as how far into it. And
117
+ * never decreasing: the spread of a set can fall when a view is replaced, and
118
+ * an operator hearing the count go backwards would reasonably think they had
119
+ * broken something.
120
+ */
121
+ export const CALIBRATION_GATES = 4;
122
+ export const CALIBRATION_STEPS_PER_GATE = 4;
123
+ export const CALIBRATION_PROGRESS_STEPS = CALIBRATION_GATES * CALIBRATION_STEPS_PER_GATE;
124
+
125
+ /**
126
+ * Which way the board still has to be turned.
127
+ *
128
+ * Two axes, one sign at a time. `top-near` and `top-far` turn it about the
129
+ * horizontal axis; `left-near` and `right-near` about the vertical one. That
130
+ * is as much as can be said without knowing where the operator is standing,
131
+ * and as much as they need, since they are looking at the same board.
132
+ *
133
+ * Here rather than beside the arithmetic that works it out, because the
134
+ * published entry carries declarations and nothing else: a consumer asking
135
+ * what the names mean must not pull in the measuring.
136
+ */
137
+ export type TiltDirection = '' | 'top-near' | 'top-far' | 'left-near' | 'right-near';
138
+
100
139
  /**
101
140
  * Where the scale of a measured pose came from.
102
141
  *
@@ -20,16 +20,28 @@ export type {
20
20
  CalibrationErrorCode,
21
21
  CalibrationGuidance,
22
22
  CalibrationStartOptions,
23
- CalibrationState
23
+ CalibrationState,
24
+ TiltDirection
25
+ } from './contract.js';
26
+ import {
27
+ CALIBRATION_PROGRESS_STEPS,
28
+ CALIBRATION_STEPS_PER_GATE
24
29
  } from './contract.js';
25
30
  import type {
26
31
  BoardPoseOptions,
27
32
  CalibrationErrorCode,
28
33
  CalibrationGuidance,
29
34
  CalibrationStartOptions,
30
- CalibrationState
35
+ CalibrationState,
36
+ TiltDirection
31
37
  } from './contract.js';
32
- import {MINIMUM_POSE_SPREAD, poseSpread} from './pose.js';
38
+ import {
39
+ MINIMUM_POSE_SPREAD,
40
+ poseSpread,
41
+ tiltDistance,
42
+ tiltOf,
43
+ weakestTiltDirection
44
+ } from './pose.js';
33
45
  import type {
34
46
  CalibrationBackendFactory,
35
47
  CalibrationBackendPort,
@@ -167,6 +179,10 @@ class CameraCalibration {
167
179
  private automatic = false;
168
180
  private cancelTick: (() => void) | undefined;
169
181
  private guidanceCode: CalibrationGuidance = '';
182
+ /** How much the view the shutter last looked at would add. */
183
+ private noveltyNow = 0;
184
+ /** The furthest along this session has been, in steps. Never falls. */
185
+ private progressReached = 0;
170
186
  /** Sample count the last automatic solve was started from. */
171
187
  private solvedFrom = 0;
172
188
 
@@ -242,6 +258,7 @@ class CameraCalibration {
242
258
  this.lease = lease;
243
259
  this.samples = [];
244
260
  this.solvedFrom = 0;
261
+ this.progressReached = 0;
245
262
  this.sessionSampleCount = 0;
246
263
  this.sampleQuality = 0;
247
264
  this.reprojectionError = 0;
@@ -294,6 +311,57 @@ class CameraCalibration {
294
311
  return this.guidanceCode;
295
312
  }
296
313
 
314
+ public novelty(): number {
315
+ return this.noveltyNow;
316
+ }
317
+
318
+ /**
319
+ * How far the session has come, in steps of the sixteen.
320
+ *
321
+ * Counted gate by gate in the order they have to be passed, stopping at the
322
+ * first one not finished -- so the number says which gate is being worked on
323
+ * as well as how far into it. Held at its highest: a set's spread can fall
324
+ * when a view is replaced, and a count that went backwards would tell the
325
+ * operator they had broken something they had not.
326
+ */
327
+ public progress(): number {
328
+ if (this.calibrationState === 'solved') return CALIBRATION_PROGRESS_STEPS;
329
+ const session = this.session;
330
+ if (!session) return this.progressReached;
331
+ const shares = [
332
+ // Enough views to solve from at all.
333
+ this.samples.length / MINIMUM_SAMPLES,
334
+ // Enough tilt among them to solve from. Nothing else can substitute:
335
+ // this is the gate a set of forty look-alikes never passes.
336
+ poseSpread(this.samples, session.board) / MINIMUM_POSE_SPREAD,
337
+ // Enough views that some can be held back from the fit.
338
+ (this.samples.length - MINIMUM_SAMPLES) /
339
+ (AUTOMATIC_COMPLETE_SAMPLES - MINIMUM_SAMPLES),
340
+ // The answer holding up on the views it was not fitted to. Before a
341
+ // solve has run there is nothing to hold up, and that is not progress.
342
+ this.holdoutCount > 0 && this.holdoutError > 0
343
+ ? session.maximumReprojectionErrorPx / this.holdoutError
344
+ : 0
345
+ ];
346
+ let steps = 0;
347
+ for (const share of shares) {
348
+ const passed = Math.max(
349
+ 0,
350
+ Math.min(CALIBRATION_STEPS_PER_GATE, Math.floor(share * CALIBRATION_STEPS_PER_GATE))
351
+ );
352
+ steps += passed;
353
+ if (passed < CALIBRATION_STEPS_PER_GATE) break;
354
+ }
355
+ this.progressReached = Math.max(this.progressReached, steps);
356
+ return this.progressReached;
357
+ }
358
+
359
+ /** Which way to turn the board next. Empty outside a live session. */
360
+ public tiltDirection(): TiltDirection {
361
+ if (!this.session || !this.lease) return '';
362
+ return weakestTiltDirection(this.samples, this.session.board);
363
+ }
364
+
297
365
  /**
298
366
  * Waits for the camera to hand over a frame with a size on it.
299
367
  *
@@ -340,6 +408,7 @@ class CameraCalibration {
340
408
 
341
409
  private stopAutomatic(): void {
342
410
  this.automatic = false;
411
+ this.noveltyNow = 0;
343
412
  this.cancelTick?.();
344
413
  this.cancelTick = undefined;
345
414
  }
@@ -808,6 +877,7 @@ class CameraCalibration {
808
877
  // one of them means fetch the other sheet. Told to "show the board"
809
878
  // while holding one, they have no reason to think anything but that the
810
879
  // camera is broken.
880
+ this.noveltyNow = 0;
811
881
  const elsewhere = detection.markersSeen > 0;
812
882
  if (automatic) return this.decline(elsewhere ? 'wrong-board' : 'show-the-board');
813
883
  if (elsewhere) {
@@ -831,6 +901,7 @@ class CameraCalibration {
831
901
  this.reject('sample-low-quality', `Sample quality must be at least ${MINIMUM_SAMPLE_QUALITY}.`);
832
902
  }
833
903
  const accepted = sample;
904
+ this.noveltyNow = this.noveltyOf(accepted, session);
834
905
  if (
835
906
  this.samples.some(
836
907
  (previous) =>
@@ -886,6 +957,30 @@ class CameraCalibration {
886
957
  this.samples.splice(dullest, 1);
887
958
  }
888
959
 
960
+ /**
961
+ * How much the view being looked at would add, from 0 to 1.
962
+ *
963
+ * Measured in tilt, not in where the corners landed. The corner distance is
964
+ * what decides whether a view is a duplicate, and it is deliberately not
965
+ * this: sliding the board across the frame moves every corner a long way and
966
+ * adds nothing a solve can use, so a signal driven by it would be loudest
967
+ * for the one motion that does not work. Tilt is what separates focal length
968
+ * from distance, so tilt is what this rewards.
969
+ *
970
+ * One is a view turned as far from everything held as the whole set is
971
+ * required to spread, which is a view worth stopping for. An empty set reads
972
+ * as one, because the first view is the most useful one there is.
973
+ */
974
+ private noveltyOf(sample: CalibrationSample, session: CalibrationSession): number {
975
+ if (this.samples.length === 0) return 1;
976
+ const tilt = tiltOf(sample, session.board);
977
+ let nearest = Number.POSITIVE_INFINITY;
978
+ for (const held of this.samples) {
979
+ nearest = Math.min(nearest, tiltDistance(tilt, tiltOf(held, session.board)));
980
+ }
981
+ return Math.max(0, Math.min(1, nearest / MINIMUM_POSE_SPREAD));
982
+ }
983
+
889
984
  /** Records what the operator should do next, without disturbing the state. */
890
985
  private guide(guidance: CalibrationGuidance): void {
891
986
  this.guidanceCode = guidance;
@@ -1095,6 +1190,18 @@ export class CameraCalibrationController {
1095
1190
  return this.existing(cameraId)?.guidance() ?? '';
1096
1191
  }
1097
1192
 
1193
+ public novelty(cameraId: string): number {
1194
+ return this.existing(cameraId)?.novelty() ?? 0;
1195
+ }
1196
+
1197
+ public tiltDirection(cameraId: string): TiltDirection {
1198
+ return this.existing(cameraId)?.tiltDirection() ?? '';
1199
+ }
1200
+
1201
+ public progress(cameraId: string): number {
1202
+ return this.existing(cameraId)?.progress() ?? 0;
1203
+ }
1204
+
1098
1205
  public cancel(cameraId: string): Promise<void> {
1099
1206
  return this.existing(cameraId)?.cancel() ?? Promise.resolve();
1100
1207
  }
@@ -1,3 +1,4 @@
1
+ import type {TiltDirection} from './contract.js';
1
2
  import type {CalibrationBoard, CalibrationCorner, CalibrationSample} from './types.js';
2
3
 
3
4
  /**
@@ -33,6 +34,48 @@ export interface Tilt {
33
34
 
34
35
  export const NO_TILT: Tilt = Object.freeze({x: 0, y: 0});
35
36
 
37
+ /**
38
+ * Which way the board still has to be turned.
39
+ *
40
+ * `x` is the upper half's grid steps against the lower half's, so a positive
41
+ * `x` is a board whose top is nearer the camera. `y` is the left half against
42
+ * the right, so a positive `y` is a board whose left edge is nearer. The names
43
+ * are in the contract; the signs they correspond to are here.
44
+ */
45
+ /**
46
+ * The direction least represented in what has been collected.
47
+ *
48
+ * Each direction is scored by the furthest any held view reaches along it, and
49
+ * the weakest wins. Asking for the weakest rather than simply "more tilt"
50
+ * turns an instruction the operator has to interpret into one they can carry
51
+ * out, and it spreads the set on purpose rather than by luck.
52
+ *
53
+ * Nothing collected asks for the first direction rather than nothing at all:
54
+ * an operator holding a board square-on has to be told to start somewhere.
55
+ */
56
+ export function weakestTiltDirection(
57
+ samples: readonly CalibrationSample[],
58
+ board: CalibrationBoard
59
+ ): TiltDirection {
60
+ const tilts = samples.map((sample) => tiltOf(sample, board));
61
+ const reach: ReadonlyArray<readonly [TiltDirection, (tilt: Tilt) => number]> = [
62
+ ['top-near', (tilt) => tilt.x],
63
+ ['top-far', (tilt) => -tilt.x],
64
+ ['left-near', (tilt) => tilt.y],
65
+ ['right-near', (tilt) => -tilt.y]
66
+ ];
67
+ let weakest: TiltDirection = 'top-near';
68
+ let smallest = Number.POSITIVE_INFINITY;
69
+ for (const [direction, along] of reach) {
70
+ const furthest = tilts.reduce((best, tilt) => Math.max(best, along(tilt)), 0);
71
+ if (furthest < smallest) {
72
+ smallest = furthest;
73
+ weakest = direction;
74
+ }
75
+ }
76
+ return weakest;
77
+ }
78
+
36
79
  /**
37
80
  * The minimum spread of tilts a solve is allowed to proceed from.
38
81
  *
@@ -43,6 +86,17 @@ export const NO_TILT: Tilt = Object.freeze({x: 0, y: 0});
43
86
  */
44
87
  export const MINIMUM_POSE_SPREAD = 0.08;
45
88
 
89
+ /**
90
+ * How differently two views were turned.
91
+ *
92
+ * The distance the solve cares about. Two views taken from the same angle
93
+ * constrain the same thing however far apart on the board they were taken, so
94
+ * this ignores where the board was and reads only how it was turned.
95
+ */
96
+ export function tiltDistance(left: Tilt, right: Tilt): number {
97
+ return Math.hypot(left.x - right.x, left.y - right.y);
98
+ }
99
+
46
100
  export function tiltOf(sample: CalibrationSample, board: CalibrationBoard): Tilt {
47
101
  const {columns, rows} = board;
48
102
  const at = new Map<number, CalibrationCorner>();
package/src/extension.ts CHANGED
@@ -125,6 +125,18 @@ export class CameraCalibrationExtension implements TurboWarpExtension {
125
125
  return this.controller.guidance(normalizeId(args.CAMERA_ID));
126
126
  }
127
127
 
128
+ public cameraCalibrationNovelty(args: {CAMERA_ID: unknown}): number {
129
+ return this.controller.novelty(normalizeId(args.CAMERA_ID));
130
+ }
131
+
132
+ public cameraCalibrationTiltDirection(args: {CAMERA_ID: unknown}): string {
133
+ return this.controller.tiltDirection(normalizeId(args.CAMERA_ID));
134
+ }
135
+
136
+ public cameraCalibrationProgress(args: {CAMERA_ID: unknown}): number {
137
+ return this.controller.progress(normalizeId(args.CAMERA_ID));
138
+ }
139
+
128
140
  public async solveCameraCalibration(args: {CAMERA_ID: unknown}): Promise<void> {
129
141
  await this.controller.solve(normalizeId(args.CAMERA_ID));
130
142
  }
@@ -262,6 +274,9 @@ export class CameraCalibrationExtension implements TurboWarpExtension {
262
274
  this.controller.setAutomatic(normalizeId(cameraId), enabled),
263
275
  automatic: (cameraId) => this.controller.automatic(normalizeId(cameraId)),
264
276
  guidance: (cameraId) => this.controller.guidance(normalizeId(cameraId)),
277
+ novelty: (cameraId) => this.controller.novelty(normalizeId(cameraId)),
278
+ tiltDirection: (cameraId) => this.controller.tiltDirection(normalizeId(cameraId)),
279
+ progress: (cameraId) => this.controller.progress(normalizeId(cameraId)),
265
280
  solve: (cameraId) => this.controller.solve(normalizeId(cameraId)),
266
281
  publish: (cameraId) => this.controller.publishProfile(normalizeId(cameraId)),
267
282
  cancel: (cameraId) => this.controller.cancel(normalizeId(cameraId)),
@@ -17,11 +17,12 @@ import type {
17
17
  CalibrationErrorCode,
18
18
  CalibrationGuidance,
19
19
  CalibrationStartOptions,
20
- CalibrationState
20
+ CalibrationState,
21
+ TiltDirection
21
22
  } from './calibration/contract.js';
22
23
 
23
24
  export const runtimeCapabilityKey = 'kubohiroyaCameraCalibrationCapability';
24
- export const runtimeCapabilityVersion = 2 as const;
25
+ export const runtimeCapabilityVersion = 4 as const;
25
26
 
26
27
  export interface CameraCalibrationCapabilityV1 {
27
28
  readonly version: typeof runtimeCapabilityVersion;
@@ -58,6 +59,40 @@ export interface CameraCalibrationCapabilityV1 {
58
59
  * recording those as errors would leave one showing for most of a session.
59
60
  */
60
61
  guidance(cameraId: string): CalibrationGuidance;
62
+ /**
63
+ * How much the view the shutter is looking at would add, 0 to 1. Since v3.
64
+ *
65
+ * Measured in tilt rather than in where the corners landed: sliding the
66
+ * board moves every corner and adds nothing a solve can use, so a signal
67
+ * driven by corner distance would be loudest for the one motion that does
68
+ * not work. One is a view turned as far from everything held as the whole
69
+ * set is required to spread. Zero when nothing usable is in frame.
70
+ *
71
+ * Meant for something continuous -- a tone, a bar, a click rate -- because
72
+ * the operator is holding the board and not reading the screen.
73
+ */
74
+ novelty(cameraId: string): number;
75
+ /**
76
+ * Which way the board still has to be turned. Since v3.
77
+ *
78
+ * `top-near`, `top-far`, `left-near`, `right-near`, or empty outside a live
79
+ * session. The direction least represented in what has been collected, so
80
+ * that "tilt it more" -- an instruction the operator has to interpret --
81
+ * becomes one they can carry out.
82
+ */
83
+ tiltDirection(cameraId: string): TiltDirection;
84
+ /**
85
+ * How far the session has come, 0 to 16. Since v4.
86
+ *
87
+ * Four gates of four steps, counted in the order they have to be passed and
88
+ * stopped at the first unfinished one -- so the number says which gate is
89
+ * being worked on as well as how far into it. Never falls.
90
+ *
91
+ * For telling the operator where they are without their reading anything:
92
+ * sixteen steps is enough to sound like progress and few enough to be heard
93
+ * as distinct. `CALIBRATION_PROGRESS_STEPS` names the total.
94
+ */
95
+ progress(cameraId: string): number;
61
96
  /** Solves from the accepted samples and releases the camera. */
62
97
  solve(cameraId: string): Promise<void>;
63
98
  /** Hands the solved profile to Camera Source, which owns the profile contract. */
@@ -155,6 +190,9 @@ export function createRuntimeCapability(
155
190
  setAutomatic: (cameraId, enabled) => host.setAutomatic(cameraId, enabled),
156
191
  automatic: (cameraId) => host.automatic(cameraId),
157
192
  guidance: (cameraId) => host.guidance(cameraId),
193
+ novelty: (cameraId) => host.novelty(cameraId),
194
+ tiltDirection: (cameraId) => host.tiltDirection(cameraId),
195
+ progress: (cameraId) => host.progress(cameraId),
158
196
  solve: (cameraId) => host.solve(cameraId),
159
197
  publish: (cameraId) => host.publish(cameraId),
160
198
  cancel: (cameraId) => host.cancel(cameraId),
package/src/runtime.ts CHANGED
@@ -16,11 +16,18 @@
16
16
  * nothing to do with versions.
17
17
  */
18
18
 
19
+ export {
20
+ CALIBRATION_GATES,
21
+ CALIBRATION_PROGRESS_STEPS,
22
+ CALIBRATION_STEPS_PER_GATE
23
+ } from './calibration/contract.js';
24
+
19
25
  export type {
20
26
  CalibrationErrorCode,
21
27
  CalibrationGuidance,
22
28
  CalibrationStartOptions,
23
- CalibrationState
29
+ CalibrationState,
30
+ TiltDirection
24
31
  } from './calibration/contract.js';
25
32
 
26
33
  export type {CalibrationBoard} from './calibration/types.js';