@kubohiroya/turbowarp-camera-calibration 0.9.0 → 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 +2 -2
- package/README.md +12 -2
- package/dist/camera-calibration.js +50 -2
- package/dist/extension-manifest.json +10 -0
- package/lib/calibration/contract.d.ts +24 -0
- package/lib/calibration/contract.js +24 -1
- package/lib/runtime-capability.d.ts +13 -1
- package/lib/runtime-capability.js +2 -1
- package/lib/runtime.d.ts +1 -0
- package/lib/runtime.js +1 -0
- package/package.json +1 -1
- package/src/block-definitions.json +12 -0
- package/src/calibration/contract.ts +25 -0
- package/src/calibration/controller.ts +52 -0
- package/src/extension.ts +5 -0
- package/src/runtime-capability.ts +14 -1
- package/src/runtime.ts +6 -0
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
|
@@ -268,6 +268,16 @@ Returns which way the board still has to be turned: top-near, top-far, left-near
|
|
|
268
268
|
| Opcode | `cameraCalibrationTiltDirection` |
|
|
269
269
|
| `CAMERA_ID` | String, default: `default` |
|
|
270
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
|
+
|
|
271
281
|
### `solve calibration for camera [CAMERA_ID]`
|
|
272
282
|
|
|
273
283
|
Solves the intrinsic matrix and distortion coefficients from at least eight accepted samples, then releases the camera lease. No external pose is produced.
|
|
@@ -128,6 +128,16 @@
|
|
|
128
128
|
"defaultValue": "default"
|
|
129
129
|
} }
|
|
130
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
|
+
},
|
|
131
141
|
{
|
|
132
142
|
"opcode": "solveCameraCalibration",
|
|
133
143
|
"blockType": "COMMAND",
|
|
@@ -962,6 +972,7 @@
|
|
|
962
972
|
this.automatic = false;
|
|
963
973
|
this.guidanceCode = "";
|
|
964
974
|
this.noveltyNow = 0;
|
|
975
|
+
this.progressReached = 0;
|
|
965
976
|
this.solvedFrom = 0;
|
|
966
977
|
}
|
|
967
978
|
async start(options) {
|
|
@@ -1020,6 +1031,7 @@
|
|
|
1020
1031
|
this.lease = lease;
|
|
1021
1032
|
this.samples = [];
|
|
1022
1033
|
this.solvedFrom = 0;
|
|
1034
|
+
this.progressReached = 0;
|
|
1023
1035
|
this.sessionSampleCount = 0;
|
|
1024
1036
|
this.sampleQuality = 0;
|
|
1025
1037
|
this.reprojectionError = 0;
|
|
@@ -1068,6 +1080,34 @@
|
|
|
1068
1080
|
novelty() {
|
|
1069
1081
|
return this.noveltyNow;
|
|
1070
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
|
+
}
|
|
1071
1111
|
/** Which way to turn the board next. Empty outside a live session. */
|
|
1072
1112
|
tiltDirection() {
|
|
1073
1113
|
if (!this.session || !this.lease) return "";
|
|
@@ -1664,6 +1704,9 @@
|
|
|
1664
1704
|
tiltDirection(cameraId) {
|
|
1665
1705
|
return this.existing(cameraId)?.tiltDirection() ?? "";
|
|
1666
1706
|
}
|
|
1707
|
+
progress(cameraId) {
|
|
1708
|
+
return this.existing(cameraId)?.progress() ?? 0;
|
|
1709
|
+
}
|
|
1667
1710
|
cancel(cameraId) {
|
|
1668
1711
|
return this.existing(cameraId)?.cancel() ?? Promise.resolve();
|
|
1669
1712
|
}
|
|
@@ -2207,9 +2250,9 @@
|
|
|
2207
2250
|
var runtimeCapabilityKey = "kubohiroyaCameraCalibrationCapability";
|
|
2208
2251
|
function createRuntimeCapability(host) {
|
|
2209
2252
|
const capability = {
|
|
2210
|
-
version:
|
|
2253
|
+
version: 4,
|
|
2211
2254
|
requireVersion(version) {
|
|
2212
|
-
if (!Number.isInteger(version) || version < 1 || version >
|
|
2255
|
+
if (!Number.isInteger(version) || version < 1 || version > 4) throw new Error(`Unsupported Camera Calibration runtime capability version: ${version}; this build provides 4.`);
|
|
2213
2256
|
return capability;
|
|
2214
2257
|
},
|
|
2215
2258
|
start: (options) => host.start(options),
|
|
@@ -2219,6 +2262,7 @@
|
|
|
2219
2262
|
guidance: (cameraId) => host.guidance(cameraId),
|
|
2220
2263
|
novelty: (cameraId) => host.novelty(cameraId),
|
|
2221
2264
|
tiltDirection: (cameraId) => host.tiltDirection(cameraId),
|
|
2265
|
+
progress: (cameraId) => host.progress(cameraId),
|
|
2222
2266
|
solve: (cameraId) => host.solve(cameraId),
|
|
2223
2267
|
publish: (cameraId) => host.publish(cameraId),
|
|
2224
2268
|
cancel: (cameraId) => host.cancel(cameraId),
|
|
@@ -2326,6 +2370,9 @@
|
|
|
2326
2370
|
cameraCalibrationTiltDirection(args) {
|
|
2327
2371
|
return this.controller.tiltDirection(normalizeId(args.CAMERA_ID));
|
|
2328
2372
|
}
|
|
2373
|
+
cameraCalibrationProgress(args) {
|
|
2374
|
+
return this.controller.progress(normalizeId(args.CAMERA_ID));
|
|
2375
|
+
}
|
|
2329
2376
|
async solveCameraCalibration(args) {
|
|
2330
2377
|
await this.controller.solve(normalizeId(args.CAMERA_ID));
|
|
2331
2378
|
}
|
|
@@ -2414,6 +2461,7 @@
|
|
|
2414
2461
|
guidance: (cameraId) => this.controller.guidance(normalizeId(cameraId)),
|
|
2415
2462
|
novelty: (cameraId) => this.controller.novelty(normalizeId(cameraId)),
|
|
2416
2463
|
tiltDirection: (cameraId) => this.controller.tiltDirection(normalizeId(cameraId)),
|
|
2464
|
+
progress: (cameraId) => this.controller.progress(normalizeId(cameraId)),
|
|
2417
2465
|
solve: (cameraId) => this.controller.solve(normalizeId(cameraId)),
|
|
2418
2466
|
publish: (cameraId) => this.controller.publishProfile(normalizeId(cameraId)),
|
|
2419
2467
|
cancel: (cameraId) => this.controller.cancel(normalizeId(cameraId)),
|
|
@@ -131,6 +131,16 @@
|
|
|
131
131
|
}
|
|
132
132
|
]
|
|
133
133
|
},
|
|
134
|
+
{
|
|
135
|
+
"opcode": "cameraCalibrationProgress",
|
|
136
|
+
"blockType": "REPORTER",
|
|
137
|
+
"arguments": [
|
|
138
|
+
{
|
|
139
|
+
"id": "CAMERA_ID",
|
|
140
|
+
"type": "STRING"
|
|
141
|
+
}
|
|
142
|
+
]
|
|
143
|
+
},
|
|
134
144
|
{
|
|
135
145
|
"opcode": "cameraCalibrationReady",
|
|
136
146
|
"blockType": "BOOLEAN",
|
|
@@ -60,6 +60,30 @@ 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;
|
|
63
87
|
/**
|
|
64
88
|
* Which way the board still has to be turned.
|
|
65
89
|
*
|
|
@@ -1 +1,24 @@
|
|
|
1
|
-
|
|
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;
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
*/
|
|
15
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:
|
|
17
|
+
export declare const runtimeCapabilityVersion: 4;
|
|
18
18
|
export interface CameraCalibrationCapabilityV1 {
|
|
19
19
|
readonly version: typeof runtimeCapabilityVersion;
|
|
20
20
|
requireVersion(version: number): CameraCalibrationCapabilityV1;
|
|
@@ -71,6 +71,18 @@ export interface CameraCalibrationCapabilityV1 {
|
|
|
71
71
|
* becomes one they can carry out.
|
|
72
72
|
*/
|
|
73
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;
|
|
74
86
|
/** Solves from the accepted samples and releases the camera. */
|
|
75
87
|
solve(cameraId: string): Promise<void>;
|
|
76
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
|
+
export const runtimeCapabilityVersion = 4;
|
|
3
3
|
export function createRuntimeCapability(host) {
|
|
4
4
|
const capability = {
|
|
5
5
|
version: runtimeCapabilityVersion,
|
|
@@ -22,6 +22,7 @@ export function createRuntimeCapability(host) {
|
|
|
22
22
|
guidance: (cameraId) => host.guidance(cameraId),
|
|
23
23
|
novelty: (cameraId) => host.novelty(cameraId),
|
|
24
24
|
tiltDirection: (cameraId) => host.tiltDirection(cameraId),
|
|
25
|
+
progress: (cameraId) => host.progress(cameraId),
|
|
25
26
|
solve: (cameraId) => host.solve(cameraId),
|
|
26
27
|
publish: (cameraId) => host.publish(cameraId),
|
|
27
28
|
cancel: (cameraId) => host.cancel(cameraId),
|
package/lib/runtime.d.ts
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 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';
|
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.
|
|
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",
|
|
@@ -121,6 +121,18 @@
|
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
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
|
+
},
|
|
124
136
|
{
|
|
125
137
|
"opcode": "solveCameraCalibration",
|
|
126
138
|
"blockType": "COMMAND",
|
|
@@ -97,6 +97,31 @@ 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
|
+
|
|
100
125
|
/**
|
|
101
126
|
* Which way the board still has to be turned.
|
|
102
127
|
*
|
|
@@ -23,6 +23,10 @@ export type {
|
|
|
23
23
|
CalibrationState,
|
|
24
24
|
TiltDirection
|
|
25
25
|
} from './contract.js';
|
|
26
|
+
import {
|
|
27
|
+
CALIBRATION_PROGRESS_STEPS,
|
|
28
|
+
CALIBRATION_STEPS_PER_GATE
|
|
29
|
+
} from './contract.js';
|
|
26
30
|
import type {
|
|
27
31
|
BoardPoseOptions,
|
|
28
32
|
CalibrationErrorCode,
|
|
@@ -177,6 +181,8 @@ class CameraCalibration {
|
|
|
177
181
|
private guidanceCode: CalibrationGuidance = '';
|
|
178
182
|
/** How much the view the shutter last looked at would add. */
|
|
179
183
|
private noveltyNow = 0;
|
|
184
|
+
/** The furthest along this session has been, in steps. Never falls. */
|
|
185
|
+
private progressReached = 0;
|
|
180
186
|
/** Sample count the last automatic solve was started from. */
|
|
181
187
|
private solvedFrom = 0;
|
|
182
188
|
|
|
@@ -252,6 +258,7 @@ class CameraCalibration {
|
|
|
252
258
|
this.lease = lease;
|
|
253
259
|
this.samples = [];
|
|
254
260
|
this.solvedFrom = 0;
|
|
261
|
+
this.progressReached = 0;
|
|
255
262
|
this.sessionSampleCount = 0;
|
|
256
263
|
this.sampleQuality = 0;
|
|
257
264
|
this.reprojectionError = 0;
|
|
@@ -308,6 +315,47 @@ class CameraCalibration {
|
|
|
308
315
|
return this.noveltyNow;
|
|
309
316
|
}
|
|
310
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
|
+
|
|
311
359
|
/** Which way to turn the board next. Empty outside a live session. */
|
|
312
360
|
public tiltDirection(): TiltDirection {
|
|
313
361
|
if (!this.session || !this.lease) return '';
|
|
@@ -1150,6 +1198,10 @@ export class CameraCalibrationController {
|
|
|
1150
1198
|
return this.existing(cameraId)?.tiltDirection() ?? '';
|
|
1151
1199
|
}
|
|
1152
1200
|
|
|
1201
|
+
public progress(cameraId: string): number {
|
|
1202
|
+
return this.existing(cameraId)?.progress() ?? 0;
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1153
1205
|
public cancel(cameraId: string): Promise<void> {
|
|
1154
1206
|
return this.existing(cameraId)?.cancel() ?? Promise.resolve();
|
|
1155
1207
|
}
|
package/src/extension.ts
CHANGED
|
@@ -133,6 +133,10 @@ export class CameraCalibrationExtension implements TurboWarpExtension {
|
|
|
133
133
|
return this.controller.tiltDirection(normalizeId(args.CAMERA_ID));
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
+
public cameraCalibrationProgress(args: {CAMERA_ID: unknown}): number {
|
|
137
|
+
return this.controller.progress(normalizeId(args.CAMERA_ID));
|
|
138
|
+
}
|
|
139
|
+
|
|
136
140
|
public async solveCameraCalibration(args: {CAMERA_ID: unknown}): Promise<void> {
|
|
137
141
|
await this.controller.solve(normalizeId(args.CAMERA_ID));
|
|
138
142
|
}
|
|
@@ -272,6 +276,7 @@ export class CameraCalibrationExtension implements TurboWarpExtension {
|
|
|
272
276
|
guidance: (cameraId) => this.controller.guidance(normalizeId(cameraId)),
|
|
273
277
|
novelty: (cameraId) => this.controller.novelty(normalizeId(cameraId)),
|
|
274
278
|
tiltDirection: (cameraId) => this.controller.tiltDirection(normalizeId(cameraId)),
|
|
279
|
+
progress: (cameraId) => this.controller.progress(normalizeId(cameraId)),
|
|
275
280
|
solve: (cameraId) => this.controller.solve(normalizeId(cameraId)),
|
|
276
281
|
publish: (cameraId) => this.controller.publishProfile(normalizeId(cameraId)),
|
|
277
282
|
cancel: (cameraId) => this.controller.cancel(normalizeId(cameraId)),
|
|
@@ -22,7 +22,7 @@ import type {
|
|
|
22
22
|
} from './calibration/contract.js';
|
|
23
23
|
|
|
24
24
|
export const runtimeCapabilityKey = 'kubohiroyaCameraCalibrationCapability';
|
|
25
|
-
export const runtimeCapabilityVersion =
|
|
25
|
+
export const runtimeCapabilityVersion = 4 as const;
|
|
26
26
|
|
|
27
27
|
export interface CameraCalibrationCapabilityV1 {
|
|
28
28
|
readonly version: typeof runtimeCapabilityVersion;
|
|
@@ -81,6 +81,18 @@ export interface CameraCalibrationCapabilityV1 {
|
|
|
81
81
|
* becomes one they can carry out.
|
|
82
82
|
*/
|
|
83
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;
|
|
84
96
|
/** Solves from the accepted samples and releases the camera. */
|
|
85
97
|
solve(cameraId: string): Promise<void>;
|
|
86
98
|
/** Hands the solved profile to Camera Source, which owns the profile contract. */
|
|
@@ -180,6 +192,7 @@ export function createRuntimeCapability(
|
|
|
180
192
|
guidance: (cameraId) => host.guidance(cameraId),
|
|
181
193
|
novelty: (cameraId) => host.novelty(cameraId),
|
|
182
194
|
tiltDirection: (cameraId) => host.tiltDirection(cameraId),
|
|
195
|
+
progress: (cameraId) => host.progress(cameraId),
|
|
183
196
|
solve: (cameraId) => host.solve(cameraId),
|
|
184
197
|
publish: (cameraId) => host.publish(cameraId),
|
|
185
198
|
cancel: (cameraId) => host.cancel(cameraId),
|
package/src/runtime.ts
CHANGED