@kubohiroya/turbowarp-camera-source 0.7.0 → 0.9.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 -11
- package/README.md +3 -9
- package/dist/calibration/adaptation.d.ts +64 -0
- package/dist/calibration/adaptation.d.ts.map +1 -0
- package/dist/calibration/adaptation.js +111 -0
- package/dist/calibration/adaptation.js.map +1 -0
- package/dist/calibration/compatibility.d.ts +44 -0
- package/dist/calibration/compatibility.d.ts.map +1 -0
- package/dist/calibration/compatibility.js +95 -0
- package/dist/calibration/compatibility.js.map +1 -0
- package/dist/calibration/conditions.d.ts +67 -0
- package/dist/calibration/conditions.d.ts.map +1 -0
- package/dist/calibration/conditions.js +61 -0
- package/dist/calibration/conditions.js.map +1 -0
- package/dist/calibration/types.d.ts +135 -0
- package/dist/calibration/types.d.ts.map +1 -0
- package/dist/calibration/types.js +13 -0
- package/dist/calibration/types.js.map +1 -0
- package/dist/camera-source.js +26 -34
- package/dist/flip.d.ts +24 -0
- package/dist/flip.d.ts.map +1 -0
- package/dist/flip.js +33 -0
- package/dist/flip.js.map +1 -0
- package/dist/runtime-capability.d.ts +70 -0
- package/dist/runtime-capability.d.ts.map +1 -0
- package/dist/runtime-capability.js +26 -0
- package/dist/runtime-capability.js.map +1 -0
- package/dist/runtime.d.ts +36 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +30 -1
- package/dist/runtime.js.map +1 -1
- package/package.json +1 -1
package/README.ja.md
CHANGED
|
@@ -26,13 +26,13 @@ TurboWarp-Camera-Sourceは、MediaDevicesのカメラストリームを名前付
|
|
|
26
26
|
次のURLをunsandboxed custom extensionとして読み込みます。
|
|
27
27
|
|
|
28
28
|
```text
|
|
29
|
-
https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-camera-source@0.
|
|
29
|
+
https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-camera-source@0.9.0/dist/camera-source.js
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
npm hostでは次を使います。
|
|
33
33
|
|
|
34
34
|
```bash
|
|
35
|
-
pnpm add @kubohiroya/turbowarp-camera-source@0.
|
|
35
|
+
pnpm add @kubohiroya/turbowarp-camera-source@0.9.0
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
## Quick start
|
|
@@ -69,9 +69,6 @@ stop shared camera [pose]
|
|
|
69
69
|
- `camera device count`: 更新済みカメラデバイス数を返します。
|
|
70
70
|
- `camera device ID at [INDEX]`: 1始まりの位置でカメラdevice IDを返します。
|
|
71
71
|
- `camera device label at [INDEX]`: 1始まりの位置でカメララベルを返します。
|
|
72
|
-
|
|
73
|
-
次の12ブロックは`calibrationProfilesV1`フラグがONのときだけパレットに出ます(既定OFF)。
|
|
74
|
-
|
|
75
72
|
- `register camera profile [PROFILE_JSON]`: 内部校正プロファイルを検証して登録します。現行の`twcs/camera-intrinsics`と、旧`twrmc/camera-calibration`のどちらの文書も受け取ります。
|
|
76
73
|
- `forget camera profile for [CAMERA_ID]`: 登録済みプロファイルを破棄します。
|
|
77
74
|
- `camera [CAMERA_ID] is calibrated?`: プロファイルが登録されているかを返します。未登録は正常な状態です。
|
|
@@ -147,12 +144,6 @@ Scratchのtouchingまたはcolor sensing用の画像sourceとしては扱いま
|
|
|
147
144
|
|
|
148
145
|
内部校正プロファイルの契約は本拡張が持つが、**プロファイルを作ることはしない**。チェスボード校正も、操作者が貼り付けたJSONも、将来の別方式も、検証を通る文書の生産者というだけで、ここからは区別できない。
|
|
149
146
|
|
|
150
|
-
この面は`config/feature-flags.ts`の起動時固定フラグで囲ってあり、**既定はOFF**。カメラ取得とpreviewはどちらでも変わらない。
|
|
151
|
-
|
|
152
|
-
```js
|
|
153
|
-
globalThis.__TWCS_FEATURE_FLAGS__ = {calibrationProfilesV1: true};
|
|
154
|
-
```
|
|
155
|
-
|
|
156
147
|
**プロファイルはカメラの投影の仕方を述べるもので、どこに立っているかは述べない。** 共通world座標での姿勢は配置を解く拡張の責務で、両者を1つの文書に混ぜたことが、従来の`twrmc/camera-calibration`形式を出自のアプリ以外で使えなくしていた。旧文書は読めるが、その姿勢は配置として再公開せずに捨てる。
|
|
157
148
|
|
|
158
149
|
**プロファイルを自分でスケールせず、内部行列を要求すること。** 校正時と違う解像度で届く場合、必要な計算は何が起きたかで変わる。単純な縮小なら`fx`・`fy`・`cx`・`cy`を比率倍するが、cropなら焦点距離はそのままで主点が平行移動する。trackの`resizeMode`を見られるのは本拡張だけなので、両者を区別できるのも本拡張だけ。**利用側がそれぞれ推測すれば、それぞれ違う推測をし、同じカメラがどの拡張から尋ねたかで違う幾何を返すことになる。** `camera intrinsics JSON`は現在のフレームに適合済みの数値を返し、cropやアスペクト変更で主点を置けない場合は空文字を返す。
|
package/README.md
CHANGED
|
@@ -30,13 +30,13 @@ or select separate cameras for separate roles.
|
|
|
30
30
|
Load this URL as an unsandboxed custom extension:
|
|
31
31
|
|
|
32
32
|
```text
|
|
33
|
-
https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-camera-source@0.
|
|
33
|
+
https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-camera-source@0.9.0/dist/camera-source.js
|
|
34
34
|
```
|
|
35
35
|
|
|
36
36
|
For npm hosts:
|
|
37
37
|
|
|
38
38
|
```bash
|
|
39
|
-
pnpm add @kubohiroya/turbowarp-camera-source@0.
|
|
39
|
+
pnpm add @kubohiroya/turbowarp-camera-source@0.9.0
|
|
40
40
|
```
|
|
41
41
|
|
|
42
42
|
## Quick Start
|
|
@@ -393,13 +393,7 @@ noninteractive; it is intended for display, not Scratch touching or color-sensin
|
|
|
393
393
|
|
|
394
394
|
This extension owns the contract for intrinsic calibration profiles but never produces one. Chessboard calibration, an operator pasting JSON, and any future calibrator are all just producers of a document that passes validation, and nothing here can tell them apart.
|
|
395
395
|
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
```js
|
|
399
|
-
globalThis.__TWCS_FEATURE_FLAGS__ = {calibrationProfilesV1: true};
|
|
400
|
-
```
|
|
401
|
-
|
|
402
|
-
A versioned capability is published for other extensions:
|
|
396
|
+
A versioned capability is published for other extensions, always:
|
|
403
397
|
|
|
404
398
|
```js
|
|
405
399
|
const calibration = Scratch.vm.runtime.kubohiroyaCameraSourceCapability.requireVersion(1);
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Re-expresses a profile for a frame size it was not solved at.
|
|
3
|
+
*
|
|
4
|
+
* A consumer that finds a 1920x1080 profile against a 1280x720 frame has to do
|
|
5
|
+
* something, and the arithmetic is not obvious: a pure downscale multiplies
|
|
6
|
+
* `fx`, `fy`, `cx` and `cy` by the ratio, while a crop leaves the focal lengths
|
|
7
|
+
* alone and shifts the principal point instead. The two produce different
|
|
8
|
+
* geometry from the same pair of numbers.
|
|
9
|
+
*
|
|
10
|
+
* Only this extension can tell which happened, because only it sees the track's
|
|
11
|
+
* `resizeMode` and the device's own reporting. Leaving the choice to consumers
|
|
12
|
+
* means each of them guesses, and they guess differently: the same camera then
|
|
13
|
+
* yields different placements depending on which extension asked. So the
|
|
14
|
+
* decision, and the adapted numbers, are produced here.
|
|
15
|
+
*
|
|
16
|
+
* Distortion coefficients are left untouched. They are defined against
|
|
17
|
+
* normalised image coordinates, so a uniform scale does not change them.
|
|
18
|
+
*/
|
|
19
|
+
import type { CompatibilityReport } from './compatibility.js';
|
|
20
|
+
import type { CameraConditions } from './conditions.js';
|
|
21
|
+
import type { CameraIntrinsicProfileV1, CameraIntrinsics } from './types.js';
|
|
22
|
+
export type AdaptationState = 'exact' | 'scaled' | 'unavailable';
|
|
23
|
+
export type AdaptationCode = 'exact' | 'uniform-scale' | 'no-frame' | 'aspect-changed' | 'cropped' | 'undistorted-frames';
|
|
24
|
+
export interface ProfileAdaptation {
|
|
25
|
+
readonly state: AdaptationState;
|
|
26
|
+
readonly code: AdaptationCode;
|
|
27
|
+
/** The intrinsics to project the current frames with, when there are any. */
|
|
28
|
+
readonly intrinsics?: CameraIntrinsics;
|
|
29
|
+
readonly width: number;
|
|
30
|
+
readonly height: number;
|
|
31
|
+
/** The factor applied, 1 when the sizes already agreed. */
|
|
32
|
+
readonly scale: number;
|
|
33
|
+
readonly detail: string;
|
|
34
|
+
}
|
|
35
|
+
export declare function adaptProfileToConditions(profile: CameraIntrinsicProfileV1, conditions: CameraConditions): ProfileAdaptation;
|
|
36
|
+
export declare function scaleIntrinsics(intrinsics: CameraIntrinsics, scale: number): CameraIntrinsics;
|
|
37
|
+
/**
|
|
38
|
+
* Numbers a consumer may actually project with.
|
|
39
|
+
*
|
|
40
|
+
* Separate from the stored profile and from the adaptation on purpose. Those two answer "what is
|
|
41
|
+
* held" and "how would it be re-expressed", which are questions worth asking about a profile that
|
|
42
|
+
* does not fit; this answers "what may be used", and it exists only when the answer is something.
|
|
43
|
+
*/
|
|
44
|
+
export interface UsableIntrinsics extends CameraIntrinsics {
|
|
45
|
+
/** The frame size these numbers belong to. */
|
|
46
|
+
readonly width: number;
|
|
47
|
+
readonly height: number;
|
|
48
|
+
readonly scale: number;
|
|
49
|
+
readonly adaptation: AdaptationState;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The intrinsics to use, if there are any.
|
|
53
|
+
*
|
|
54
|
+
* Both conditions have to hold, and they are different questions. Compatibility asks whether this
|
|
55
|
+
* profile describes this camera as it is configured now; adaptation asks whether the numbers can be
|
|
56
|
+
* expressed for the frame size in front of us. A profile can fit the camera and still have no usable
|
|
57
|
+
* form — a crop, say — and it can adapt cleanly while belonging to a different camera entirely.
|
|
58
|
+
*
|
|
59
|
+
* Returning undefined rather than the stored numbers is the whole point. Intrinsics from another
|
|
60
|
+
* configuration do not fail visibly: they project, and the geometry that comes back looks like a
|
|
61
|
+
* slightly different camera pose rather than like a mistake.
|
|
62
|
+
*/
|
|
63
|
+
export declare function usableIntrinsics(compatibility: CompatibilityReport, adaptation: ProfileAdaptation): UsableIntrinsics | undefined;
|
|
64
|
+
//# sourceMappingURL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AE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,UAAU,EAAE,eAAe,CAAC;CACtC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAC9B,aAAa,EAAE,mBAAmB,EAClC,UAAU,EAAE,iBAAiB,GAC5B,gBAAgB,GAAG,SAAS,CAU9B"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/** Aspect ratios are compared with a tolerance; reported sizes are whole pixels. */
|
|
2
|
+
const ASPECT_TOLERANCE = 1e-3;
|
|
3
|
+
export function adaptProfileToConditions(profile, conditions) {
|
|
4
|
+
const { width: calibratedWidth, height: calibratedHeight } = profile.image;
|
|
5
|
+
const { width, height } = conditions;
|
|
6
|
+
if (width === 0 || height === 0) {
|
|
7
|
+
return {
|
|
8
|
+
state: 'unavailable',
|
|
9
|
+
code: 'no-frame',
|
|
10
|
+
width,
|
|
11
|
+
height,
|
|
12
|
+
scale: 1,
|
|
13
|
+
detail: 'The camera has delivered no frame yet, so there is no size to adapt to.'
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
if (width === calibratedWidth && height === calibratedHeight) {
|
|
17
|
+
return {
|
|
18
|
+
state: 'exact',
|
|
19
|
+
code: 'exact',
|
|
20
|
+
intrinsics: profile.intrinsics,
|
|
21
|
+
width,
|
|
22
|
+
height,
|
|
23
|
+
scale: 1,
|
|
24
|
+
detail: `The frame is ${width}x${height}, as calibrated.`
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
if (profile.image.undistorted) {
|
|
28
|
+
// The profile describes frames something upstream has already corrected.
|
|
29
|
+
// Scaling its intrinsics would describe a correction of a different image.
|
|
30
|
+
return {
|
|
31
|
+
state: 'unavailable',
|
|
32
|
+
code: 'undistorted-frames',
|
|
33
|
+
width,
|
|
34
|
+
height,
|
|
35
|
+
scale: 1,
|
|
36
|
+
detail: 'The profile describes already undistorted images, so it cannot be re-expressed for a different frame size here.'
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
if (profile.capture?.resizeMode === 'crop-and-scale') {
|
|
40
|
+
// The track may crop before it scales, which moves the principal point by
|
|
41
|
+
// an amount nothing here reports. Guessing a pure scale would put the
|
|
42
|
+
// optical centre in the wrong place and the error would look like a
|
|
43
|
+
// slightly rotated camera rather than a mistake.
|
|
44
|
+
return {
|
|
45
|
+
state: 'unavailable',
|
|
46
|
+
code: 'cropped',
|
|
47
|
+
width,
|
|
48
|
+
height,
|
|
49
|
+
scale: 1,
|
|
50
|
+
detail: 'The track was calibrated with crop-and-scale resizing, so a different frame size may be a crop rather than a scale and the principal point cannot be placed.'
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
const scaleX = width / calibratedWidth;
|
|
54
|
+
const scaleY = height / calibratedHeight;
|
|
55
|
+
if (Math.abs(scaleX - scaleY) > ASPECT_TOLERANCE) {
|
|
56
|
+
return {
|
|
57
|
+
state: 'unavailable',
|
|
58
|
+
code: 'aspect-changed',
|
|
59
|
+
width,
|
|
60
|
+
height,
|
|
61
|
+
scale: 1,
|
|
62
|
+
detail: `The calibrated ${calibratedWidth}x${calibratedHeight} and the current ${width}x${height} have different aspect ratios, so the difference is not a scale.`
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
const scale = (scaleX + scaleY) / 2;
|
|
66
|
+
return {
|
|
67
|
+
state: 'scaled',
|
|
68
|
+
code: 'uniform-scale',
|
|
69
|
+
intrinsics: scaleIntrinsics(profile.intrinsics, scale),
|
|
70
|
+
width,
|
|
71
|
+
height,
|
|
72
|
+
scale,
|
|
73
|
+
detail: `The calibrated ${calibratedWidth}x${calibratedHeight} has been scaled by ${scale} to the current ${width}x${height}.`
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
export function scaleIntrinsics(intrinsics, scale) {
|
|
77
|
+
return {
|
|
78
|
+
fx: intrinsics.fx * scale,
|
|
79
|
+
fy: intrinsics.fy * scale,
|
|
80
|
+
cx: intrinsics.cx * scale,
|
|
81
|
+
cy: intrinsics.cy * scale,
|
|
82
|
+
// Skew is a ratio between the axes, so a uniform scale leaves it alone.
|
|
83
|
+
skew: intrinsics.skew
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The intrinsics to use, if there are any.
|
|
88
|
+
*
|
|
89
|
+
* Both conditions have to hold, and they are different questions. Compatibility asks whether this
|
|
90
|
+
* profile describes this camera as it is configured now; adaptation asks whether the numbers can be
|
|
91
|
+
* expressed for the frame size in front of us. A profile can fit the camera and still have no usable
|
|
92
|
+
* form — a crop, say — and it can adapt cleanly while belonging to a different camera entirely.
|
|
93
|
+
*
|
|
94
|
+
* Returning undefined rather than the stored numbers is the whole point. Intrinsics from another
|
|
95
|
+
* configuration do not fail visibly: they project, and the geometry that comes back looks like a
|
|
96
|
+
* slightly different camera pose rather than like a mistake.
|
|
97
|
+
*/
|
|
98
|
+
export function usableIntrinsics(compatibility, adaptation) {
|
|
99
|
+
if (compatibility.state !== 'compatible')
|
|
100
|
+
return undefined;
|
|
101
|
+
if (adaptation.intrinsics === undefined)
|
|
102
|
+
return undefined;
|
|
103
|
+
return {
|
|
104
|
+
...adaptation.intrinsics,
|
|
105
|
+
width: adaptation.width,
|
|
106
|
+
height: adaptation.height,
|
|
107
|
+
scale: adaptation.scale,
|
|
108
|
+
adaptation: adaptation.state
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=adaptation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adaptation.js","sourceRoot":"","sources":["../../src/calibration/adaptation.ts"],"names":[],"mappings":"AA4CA,oFAAoF;AACpF,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAE9B,MAAM,UAAU,wBAAwB,CACtC,OAAiC,EACjC,UAA4B;IAE5B,MAAM,EAAC,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,gBAAgB,EAAC,GAAG,OAAO,CAAC,KAAK,CAAC;IACz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AAU,CAAC,MAAM;QACzB,KAAK,EAAE,UAAU,CAAC,KAAK;QACvB,UAAU,EAAE,UAAU,CAAC,KAAK;KAC7B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decides whether a stored profile still describes the camera in front of us.
|
|
3
|
+
*
|
|
4
|
+
* The verdict has three values, not two. "Cannot tell" is a distinct answer from "fits", and
|
|
5
|
+
* collapsing the two is how a consumer ends up projecting with intrinsics that belong to a
|
|
6
|
+
* different capture configuration — an error that produces plausible geometry rather than a
|
|
7
|
+
* visible failure. A caller that only looks for `compatible` gets the safe behaviour by default.
|
|
8
|
+
*
|
|
9
|
+
* Every finding carries whether it decided the verdict, so an operator can be shown the one thing
|
|
10
|
+
* that has to change without a frame rate difference looking like a reason to recalibrate.
|
|
11
|
+
*/
|
|
12
|
+
import type { CameraConditions } from './conditions.js';
|
|
13
|
+
import type { CameraIntrinsicProfileV1 } from './types.js';
|
|
14
|
+
export type CompatibilityState = 'compatible' | 'incompatible' | 'undetermined';
|
|
15
|
+
export type FindingState = 'matched' | 'mismatched' | 'unknown';
|
|
16
|
+
export type CompatibilityCode = 'image-size' | 'capture-conditions' | 'resize-mode' | 'zoom' | 'focus-mode' | 'focus-distance' | 'frame-rate' | 'facing-mode' | 'undistorted-frames' | 'device-label' | 'device-id';
|
|
17
|
+
export interface CompatibilityFinding {
|
|
18
|
+
readonly code: CompatibilityCode;
|
|
19
|
+
readonly state: FindingState;
|
|
20
|
+
/**
|
|
21
|
+
* Whether this finding took part in the verdict.
|
|
22
|
+
*
|
|
23
|
+
* A non-decisive finding is recorded for the operator and nothing else: frame rate and facing mode
|
|
24
|
+
* do not change how a lens projects, and a browser-scoped device id changes without the camera
|
|
25
|
+
* changing, so none of them may push a profile to `incompatible`.
|
|
26
|
+
*/
|
|
27
|
+
readonly decisive: boolean;
|
|
28
|
+
readonly detail: string;
|
|
29
|
+
}
|
|
30
|
+
export interface CompatibilityReport {
|
|
31
|
+
readonly state: CompatibilityState;
|
|
32
|
+
readonly findings: readonly CompatibilityFinding[];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Judges a profile against the conditions a camera reports.
|
|
36
|
+
*
|
|
37
|
+
* The verdict is `incompatible` when any decisive finding mismatched, `undetermined` when any
|
|
38
|
+
* decisive finding could not be settled, and `compatible` only when every decisive finding matched.
|
|
39
|
+
* Unknown never resolves upward into `compatible`.
|
|
40
|
+
*/
|
|
41
|
+
export declare function evaluateProfileCompatibility(profile: CameraIntrinsicProfileV1, conditions: CameraConditions): CompatibilityReport;
|
|
42
|
+
/** The findings that decided the verdict, in the order they were made. */
|
|
43
|
+
export declare function decisiveFindings(report: CompatibilityReport): readonly CompatibilityFinding[];
|
|
44
|
+
//# sourceMappingURL=compatibility.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compatibility.d.ts","sourceRoot":"","sources":["../../src/calibration/compatibility.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAqB,wBAAwB,EAAC,MAAM,YAAY,CAAC;AAE7E,MAAM,MAAM,kBAAkB,GAAG,YAAY,GAAG,cAAc,GAAG,cAAc,CAAC;AAEhF,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,YAAY,GAAG,SAAS,CAAC;AAEhE,MAAM,MAAM,iBAAiB,GACzB,YAAY,GACZ,oBAAoB,GACpB,aAAa,GACb,MAAM,GACN,YAAY,GACZ,gBAAgB,GAChB,YAAY,GACZ,aAAa,GACb,oBAAoB,GACpB,cAAc,GACd,WAAW,CAAC;AAEhB,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;IACjC,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B;;;;;;OAMG;IACH,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,KAAK,EAAE,kBAAkB,CAAC;IACnC,QAAQ,CAAC,QAAQ,EAAE,SAAS,oBAAoB,EAAE,CAAC;CACpD;AA4ID;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,wBAAwB,EACjC,UAAU,EAAE,gBAAgB,GAC3B,mBAAmB,CAmDrB;AAED,0EAA0E;AAC1E,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,mBAAmB,GAAG,SAAS,oBAAoB,EAAE,CAE7F"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/** Zoom readings are device-reported floats; compare them with a tolerance rather than exactly. */
|
|
2
|
+
const ZOOM_TOLERANCE = 1e-6;
|
|
3
|
+
const FOCUS_DISTANCE_TOLERANCE = 1e-6;
|
|
4
|
+
function finding(code, state, decisive, detail) {
|
|
5
|
+
return { code, state, decisive, detail };
|
|
6
|
+
}
|
|
7
|
+
function describe(value) {
|
|
8
|
+
return value === undefined ? 'not reported' : String(value);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Compares one optical member.
|
|
12
|
+
*
|
|
13
|
+
* Absent on both sides is agreement, not ignorance: the device reported no such control when the
|
|
14
|
+
* calibration was solved and reports none now. Present on one side only is a change nobody can
|
|
15
|
+
* quantify, so it is left unknown rather than guessed in either direction.
|
|
16
|
+
*/
|
|
17
|
+
function compareMember(code, name, recorded, observed, equal) {
|
|
18
|
+
if (recorded === undefined && observed === undefined) {
|
|
19
|
+
return finding(code, 'matched', true, `Neither the profile nor the camera reports ${name}.`);
|
|
20
|
+
}
|
|
21
|
+
if (recorded === undefined || observed === undefined) {
|
|
22
|
+
return finding(code, 'unknown', true, `${name} is ${describe(recorded)} in the profile and ${describe(observed)} now, so the two cannot be compared.`);
|
|
23
|
+
}
|
|
24
|
+
const same = equal(recorded, observed);
|
|
25
|
+
return finding(code, same ? 'matched' : 'mismatched', true, same
|
|
26
|
+
? `${name} is ${describe(observed)} in both.`
|
|
27
|
+
: `${name} was ${describe(recorded)} at calibration and is ${describe(observed)} now.`);
|
|
28
|
+
}
|
|
29
|
+
const sameText = (left, right) => left === right;
|
|
30
|
+
const nearlyEqual = (tolerance) => (left, right) => Math.abs(left - right) <= tolerance;
|
|
31
|
+
function captureFindings(capture, conditions) {
|
|
32
|
+
return [
|
|
33
|
+
compareMember('resize-mode', 'Resize mode', capture.resizeMode, conditions.resizeMode, sameText),
|
|
34
|
+
compareMember('zoom', 'Zoom', capture.zoom, conditions.zoom, nearlyEqual(ZOOM_TOLERANCE)),
|
|
35
|
+
compareMember('focus-mode', 'Focus mode', capture.focusMode, conditions.focusMode, sameText),
|
|
36
|
+
compareMember('focus-distance', 'Focus distance', capture.focusDistance, conditions.focusDistance, nearlyEqual(FOCUS_DISTANCE_TOLERANCE))
|
|
37
|
+
];
|
|
38
|
+
}
|
|
39
|
+
function imageSizeFinding(profile, conditions) {
|
|
40
|
+
const expected = `${profile.image.width}x${profile.image.height}`;
|
|
41
|
+
if (conditions.width === 0 || conditions.height === 0) {
|
|
42
|
+
return finding('image-size', 'unknown', true, `The camera has delivered no frame yet, so its size cannot be compared with the calibrated ${expected}.`);
|
|
43
|
+
}
|
|
44
|
+
const actual = `${conditions.width}x${conditions.height}`;
|
|
45
|
+
return actual === expected
|
|
46
|
+
? finding('image-size', 'matched', true, `The frame is ${actual}, as calibrated.`)
|
|
47
|
+
: finding('image-size', 'mismatched', true, `The calibration was solved at ${expected} and the camera now delivers ${actual}.`);
|
|
48
|
+
}
|
|
49
|
+
function deviceFindings(profile, conditions) {
|
|
50
|
+
const recordedLabel = profile.device?.label;
|
|
51
|
+
const observedLabel = conditions.label;
|
|
52
|
+
const label = recordedLabel !== undefined && observedLabel !== undefined
|
|
53
|
+
? finding('device-label', recordedLabel === observedLabel ? 'matched' : 'mismatched', true, recordedLabel === observedLabel
|
|
54
|
+
? `The camera still reports itself as ${observedLabel}.`
|
|
55
|
+
: `The profile was solved on ${recordedLabel} and the camera now reports ${observedLabel}.`)
|
|
56
|
+
: finding('device-label', 'unknown', false, 'A device label is missing on one side, which is normal before the browser grants camera permission.');
|
|
57
|
+
const recordedId = profile.device?.deviceId;
|
|
58
|
+
const observedId = conditions.deviceId.length === 0 ? undefined : conditions.deviceId;
|
|
59
|
+
const identity = finding('device-id', recordedId !== undefined && observedId !== undefined && recordedId === observedId
|
|
60
|
+
? 'matched'
|
|
61
|
+
: 'unknown', false, 'A device id is scoped to one browser and profile, so it changes without the camera changing. It is a hint for ordering candidates, never proof of identity.');
|
|
62
|
+
return [label, identity];
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Judges a profile against the conditions a camera reports.
|
|
66
|
+
*
|
|
67
|
+
* The verdict is `incompatible` when any decisive finding mismatched, `undetermined` when any
|
|
68
|
+
* decisive finding could not be settled, and `compatible` only when every decisive finding matched.
|
|
69
|
+
* Unknown never resolves upward into `compatible`.
|
|
70
|
+
*/
|
|
71
|
+
export function evaluateProfileCompatibility(profile, conditions) {
|
|
72
|
+
const findings = [imageSizeFinding(profile, conditions)];
|
|
73
|
+
if (profile.image.undistorted) {
|
|
74
|
+
findings.push(finding('undistorted-frames', 'unknown', true, 'The profile describes already undistorted images. This extension hands over the camera frames as captured and cannot confirm that something upstream corrects them.'));
|
|
75
|
+
}
|
|
76
|
+
if (profile.capture === undefined) {
|
|
77
|
+
findings.push(finding('capture-conditions', 'unknown', true, 'The profile records no capture conditions, so whether the optics are configured as they were at calibration cannot be decided.'));
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
findings.push(...captureFindings(profile.capture, conditions));
|
|
81
|
+
}
|
|
82
|
+
findings.push(finding('frame-rate', 'matched', false, `Frame rate was ${describe(profile.capture?.frameRate)} at calibration and is ${describe(conditions.frameRate)} now. It does not change how the lens projects.`), finding('facing-mode', 'matched', false, `Facing mode was ${describe(profile.capture?.facingMode)} at calibration and is ${describe(conditions.facingMode)} now.`), ...deviceFindings(profile, conditions));
|
|
83
|
+
const decisive = findings.filter((entry) => entry.decisive);
|
|
84
|
+
const state = decisive.some((entry) => entry.state === 'mismatched')
|
|
85
|
+
? 'incompatible'
|
|
86
|
+
: decisive.some((entry) => entry.state === 'unknown')
|
|
87
|
+
? 'undetermined'
|
|
88
|
+
: 'compatible';
|
|
89
|
+
return { state, findings };
|
|
90
|
+
}
|
|
91
|
+
/** The findings that decided the verdict, in the order they were made. */
|
|
92
|
+
export function decisiveFindings(report) {
|
|
93
|
+
return report.findings.filter((entry) => entry.decisive && entry.state !== 'matched');
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=compatibility.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compatibility.js","sourceRoot":"","sources":["../../src/calibration/compatibility.ts"],"names":[],"mappings":"AAkDA,mGAAmG;AACnG,MAAM,cAAc,GAAG,IAAI,CAAC;AAC5B,MAAM,wBAAwB,GAAG,IAAI,CAAC;AAEtC,SAAS,OAAO,CACd,IAAuB,EACvB,KAAmB,EACnB,QAAiB,EACjB,MAAc;IAEd,OAAO,EAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAC,CAAC;AACzC,CAAC;AAED,SAAS,QAAQ,CAAC,KAAkC;IAClD,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC9D,CAAC;AAED;;;;;;GAMG;AACH,SAAS,aAAa,CACpB,IAAuB,EACvB,IAAY,EACZ,QAAuB,EACvB,QAAuB,EACvB,KAAqC;IAErC,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QACrD,OAAO,OAAO,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,8CAA8C,IAAI,GAAG,CAAC,CAAC;IAC/F,CAAC;I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|
|
4
|
+
*
|
|
5
|
+
* This is the other half of a compatibility check: a stored profile describes the conditions a
|
|
6
|
+
* calibration was solved under, and these are the conditions in front of us. Both are read from the
|
|
7
|
+
* same `MediaTrackSettings` vocabulary so the two can be compared member by member.
|
|
8
|
+
*
|
|
9
|
+
* A member is absent when the device does not report that control at all, which is different from
|
|
10
|
+
* the control being present with an unremarkable value. The comparison depends on that difference,
|
|
11
|
+
* so nothing here substitutes a default for a missing reading.
|
|
12
|
+
*/
|
|
13
|
+
import type { CalibrationCapture } from './types.js';
|
|
14
|
+
export interface CameraConditions {
|
|
15
|
+
/** Pixel size of the delivered frame, or zero while no frame has arrived. */
|
|
16
|
+
readonly width: number;
|
|
17
|
+
readonly height: number;
|
|
18
|
+
readonly deviceId: string;
|
|
19
|
+
/**
|
|
20
|
+
* Whether the stage preview is drawn flipped.
|
|
21
|
+
*
|
|
22
|
+
* Display only. The frames handed to a consumer are the camera's own capture either way, so this
|
|
23
|
+
* never takes part in a compatibility decision — it is carried so that a caller rendering the
|
|
24
|
+
* frame knows what the operator is looking at.
|
|
25
|
+
*/
|
|
26
|
+
readonly previewFlip: Flip;
|
|
27
|
+
readonly label?: string;
|
|
28
|
+
readonly frameRate?: number;
|
|
29
|
+
readonly facingMode?: string;
|
|
30
|
+
readonly resizeMode?: string;
|
|
31
|
+
readonly zoom?: number;
|
|
32
|
+
readonly focusMode?: string;
|
|
33
|
+
readonly focusDistance?: number;
|
|
34
|
+
}
|
|
35
|
+
/** The subset of `MediaTrackSettings` this extension reads, narrowed to what it actually uses. */
|
|
36
|
+
export interface TrackSettingsLike {
|
|
37
|
+
readonly deviceId?: unknown;
|
|
38
|
+
readonly frameRate?: unknown;
|
|
39
|
+
readonly facingMode?: unknown;
|
|
40
|
+
readonly resizeMode?: unknown;
|
|
41
|
+
readonly zoom?: unknown;
|
|
42
|
+
readonly focusMode?: unknown;
|
|
43
|
+
readonly focusDistance?: unknown;
|
|
44
|
+
}
|
|
45
|
+
export interface FrameGeometry {
|
|
46
|
+
readonly width: number;
|
|
47
|
+
readonly height: number;
|
|
48
|
+
readonly previewFlip: Flip;
|
|
49
|
+
readonly deviceId: string;
|
|
50
|
+
readonly label?: string;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Builds the conditions record.
|
|
54
|
+
*
|
|
55
|
+
* Frame size comes from the delivered frame rather than from the track settings: a track can report
|
|
56
|
+
* a requested size that the browser then satisfies with something else, and the number a consumer
|
|
57
|
+
* has to match its intrinsics against is the size of the image it is actually handed.
|
|
58
|
+
*/
|
|
59
|
+
export declare function readCameraConditions(frame: FrameGeometry, settings?: TrackSettingsLike): CameraConditions;
|
|
60
|
+
/**
|
|
61
|
+
* Renders the optical part of the current conditions in the shape a profile stores.
|
|
62
|
+
*
|
|
63
|
+
* A producer solving a calibration right now uses this to record what the camera was doing, so the
|
|
64
|
+
* document it writes can later be compared against a fresh reading of the same members.
|
|
65
|
+
*/
|
|
66
|
+
export declare function captureFromConditions(conditions: CameraConditions): CalibrationCapture;
|
|
67
|
+
//# sourceMappingURL=conditions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conditions.d.ts","sourceRoot":"","sources":["../../src/calibration/conditions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,YAAY,CAAC;AACrC;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,YAAY,CAAC;AAEnD,MAAM,WAAW,gBAAgB;IAC/B,6EAA6E;IAC7E,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B;;;;;;OAMG;IACH,QAAQ,CAAC,WAAW,EAAE,IAAI,CAAC;IAC3B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,CAAC,EAAE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efined;
|
|
3
|
+
}
|
|
4
|
+
function nonNegativeNumber(value) {
|
|
5
|
+
return typeof value === 'number' && Number.isFinite(value) && value >= 0 ? value : undefined;
|
|
6
|
+
}
|
|
7
|
+
function nonEmptyText(value) {
|
|
8
|
+
if (typeof value !== 'string')
|
|
9
|
+
return undefined;
|
|
10
|
+
const text = value.trim();
|
|
11
|
+
return text.length === 0 ? undefined : text;
|
|
12
|
+
}
|
|
13
|
+
function pixelCount(value) {
|
|
14
|
+
return Number.isFinite(value) && value > 0 ? Math.round(value) : 0;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Builds the conditions record.
|
|
18
|
+
*
|
|
19
|
+
* Frame size comes from the delivered frame rather than from the track settings: a track can report
|
|
20
|
+
* a requested size that the browser then satisfies with something else, and the number a consumer
|
|
21
|
+
* has to match its intrinsics against is the size of the image it is actually handed.
|
|
22
|
+
*/
|
|
23
|
+
export function readCameraConditions(frame, settings = {}) {
|
|
24
|
+
const label = nonEmptyText(frame.label);
|
|
25
|
+
const frameRate = positiveNumber(settings.frameRate);
|
|
26
|
+
const facingMode = nonEmptyText(settings.facingMode);
|
|
27
|
+
const resizeMode = nonEmptyText(settings.resizeMode);
|
|
28
|
+
const zoom = positiveNumber(settings.zoom);
|
|
29
|
+
const focusMode = nonEmptyText(settings.focusMode);
|
|
30
|
+
const focusDistance = nonNegativeNumber(settings.focusDistance);
|
|
31
|
+
return {
|
|
32
|
+
width: pixelCount(frame.width),
|
|
33
|
+
height: pixelCount(frame.height),
|
|
34
|
+
deviceId: nonEmptyText(frame.deviceId) ?? nonEmptyText(settings.deviceId) ?? '',
|
|
35
|
+
previewFlip: frame.previewFlip,
|
|
36
|
+
...(label === undefined ? {} : { label }),
|
|
37
|
+
...(frameRate === undefined ? {} : { frameRate }),
|
|
38
|
+
...(facingMode === undefined ? {} : { facingMode }),
|
|
39
|
+
...(resizeMode === undefined ? {} : { resizeMode }),
|
|
40
|
+
...(zoom === undefined ? {} : { zoom }),
|
|
41
|
+
...(focusMode === undefined ? {} : { focusMode }),
|
|
42
|
+
...(focusDistance === undefined ? {} : { focusDistance })
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Renders the optical part of the current conditions in the shape a profile stores.
|
|
47
|
+
*
|
|
48
|
+
* A producer solving a calibration right now uses this to record what the camera was doing, so the
|
|
49
|
+
* document it writes can later be compared against a fresh reading of the same members.
|
|
50
|
+
*/
|
|
51
|
+
export function captureFromConditions(conditions) {
|
|
52
|
+
return {
|
|
53
|
+
...(conditions.frameRate === undefined ? {} : { frameRate: conditions.frameRate }),
|
|
54
|
+
...(conditions.facingMode === undefined ? {} : { facingMode: conditions.facingMode }),
|
|
55
|
+
...(conditions.resizeMode === undefined ? {} : { resizeMode: conditions.resizeMode }),
|
|
56
|
+
...(conditions.zoom === undefined ? {} : { zoom: conditions.zoom }),
|
|
57
|
+
...(conditions.focusMode === undefined ? {} : { focusMode: conditions.focusMode }),
|
|
58
|
+
...(conditions.focusDistance === undefined ? {} : { focusDistance: conditions.focusDistance })
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=conditions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conditions.js","sourceRoot":"","sources":["../../src/calibration/conditions.ts"],"names":[],"mappings":"AAuDA,SAAS,cAAc,CAAC,KAAc;IACpC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AAC9F,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAc;IACvC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AAC/F,CA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U,EAAE,UAAU,CAAC,UAAU,EAAC,CAAC;QACnF,GAAG,CAAC,UAAU,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAC,IAAI,EAAE,UAAU,CAAC,IAAI,EAAC,CAAC;QACjE,GAAG,CAAC,UAAU,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAC,SAAS,EAAE,UAAU,CAAC,SAAS,EAAC,CAAC;QAChF,GAAG,CAAC,UAAU,CAAC,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAC,aAAa,EAAE,UAAU,CAAC,aAAa,EAAC,CAAC;KAC7F,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The intrinsic calibration profile contract.
|
|
3
|
+
*
|
|
4
|
+
* A profile describes how one camera projects the world onto its own captured image. It says nothing
|
|
5
|
+
* about where that camera stands: the pose of a camera in a shared world frame belongs to whichever
|
|
6
|
+
* extension solves placement, and mixing the two into one document is what made the earlier
|
|
7
|
+
* `twrmc/camera-calibration` format unusable for anything but the application it came from.
|
|
8
|
+
*
|
|
9
|
+
* Camera Source owns the contract but never produces a profile. Chessboard calibration, an operator
|
|
10
|
+
* supplying JSON, or a future calibrator are all just producers of a document that passes validation.
|
|
11
|
+
*/
|
|
12
|
+
/** Projection model of the lens. Version 1 defines the pinhole model only. */
|
|
13
|
+
export type CameraModel = 'pinhole';
|
|
14
|
+
/**
|
|
15
|
+
* Lens distortion model.
|
|
16
|
+
*
|
|
17
|
+
* `brown-conrady` carries the OpenCV radial and tangential coefficients in their usual order
|
|
18
|
+
* (k1, k2, p1, p2 with optional k3, and k4-k6 for the rational model). `kannala-brandt` carries the
|
|
19
|
+
* four fisheye coefficients. `none` means the image is free of lens distortion.
|
|
20
|
+
*/
|
|
21
|
+
export type DistortionModel = 'none' | 'brown-conrady' | 'kannala-brandt';
|
|
22
|
+
/**
|
|
23
|
+
* The pinhole parameters, in pixels of the calibration image.
|
|
24
|
+
*
|
|
25
|
+
* Named rather than packed into a matrix because a nine-number array cannot say whether it is stored
|
|
26
|
+
* row-major or column-major, and a reader that guesses wrong produces a plausible, wrong projection.
|
|
27
|
+
* The equivalent row-major 3x3 matrix is `[fx, skew, cx, 0, fy, cy, 0, 0, 1]`.
|
|
28
|
+
*
|
|
29
|
+
* Pixel coordinates run from the top-left corner of the image, x to the right and y downward.
|
|
30
|
+
*/
|
|
31
|
+
export interface CameraIntrinsics {
|
|
32
|
+
readonly fx: number;
|
|
33
|
+
readonly fy: number;
|
|
34
|
+
readonly cx: number;
|
|
35
|
+
readonly cy: number;
|
|
36
|
+
/** Axis skew. Zero for every square-pixel sensor; kept explicit so it is never assumed. */
|
|
37
|
+
readonly skew: number;
|
|
38
|
+
}
|
|
39
|
+
export interface CameraDistortion {
|
|
40
|
+
readonly model: DistortionModel;
|
|
41
|
+
readonly coefficients: readonly number[];
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The image the calibration was solved against.
|
|
45
|
+
*
|
|
46
|
+
* `undistorted` is false for the base contract: a profile describes the raw captured frame, and a
|
|
47
|
+
* consumer applies the distortion model itself. A producer that hands over already corrected images
|
|
48
|
+
* sets it to true, which then requires the intrinsics to describe the corrected image and forbids
|
|
49
|
+
* leftover distortion coefficients.
|
|
50
|
+
*
|
|
51
|
+
* The image is always the camera's own capture. Preview mirroring is a display choice made by
|
|
52
|
+
* whoever shows the frame and never changes the calibration.
|
|
53
|
+
*/
|
|
54
|
+
export interface CalibrationImage {
|
|
55
|
+
readonly width: number;
|
|
56
|
+
readonly height: number;
|
|
57
|
+
readonly undistorted: boolean;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* How good the calibration is.
|
|
61
|
+
*
|
|
62
|
+
* Optional, because a profile can arrive from a producer that does not report it — an operator's
|
|
63
|
+
* hand-written JSON, or the legacy format, which carried no quality fields at all. Absent means
|
|
64
|
+
* unknown. A consumer that needs a quality bound must treat absence as unknown and say so, rather
|
|
65
|
+
* than reading it as a measured zero.
|
|
66
|
+
*/
|
|
67
|
+
export interface CalibrationQuality {
|
|
68
|
+
readonly sampleCount: number;
|
|
69
|
+
readonly reprojectionErrorPx: number;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Hints for recognizing the physical camera again.
|
|
73
|
+
*
|
|
74
|
+
* `deviceId` is a hint and not an identity: browsers scope it per origin and per profile, so it
|
|
75
|
+
* changes without the camera changing. Matching is done on the operator-assigned `cameraId`.
|
|
76
|
+
*/
|
|
77
|
+
export interface CalibrationDeviceHint {
|
|
78
|
+
readonly label?: string;
|
|
79
|
+
readonly deviceId?: string;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* The capture configuration the calibration was solved under.
|
|
83
|
+
*
|
|
84
|
+
* Optional as a whole, and optional member by member, but the difference between the two matters.
|
|
85
|
+
* When the block is absent nothing was recorded and compatibility cannot be decided. When it is
|
|
86
|
+
* present, a member that is absent means the device reported no such control at calibration time,
|
|
87
|
+
* which is something a later check can compare against.
|
|
88
|
+
*
|
|
89
|
+
* `frameRate` and `facingMode` are recorded for the operator; neither changes how the lens projects,
|
|
90
|
+
* so neither decides compatibility.
|
|
91
|
+
*/
|
|
92
|
+
export interface CalibrationCapture {
|
|
93
|
+
readonly frameRate?: number;
|
|
94
|
+
readonly facingMode?: string;
|
|
95
|
+
/** `none` or `crop-and-scale`. Cropping changes the effective intrinsics at the same resolution. */
|
|
96
|
+
readonly resizeMode?: string;
|
|
97
|
+
readonly zoom?: number;
|
|
98
|
+
/** `none`, `manual`, `single-shot` or `continuous`. */
|
|
99
|
+
readonly focusMode?: string;
|
|
100
|
+
readonly focusDistance?: number;
|
|
101
|
+
}
|
|
102
|
+
export interface CameraIntrinsicProfileV1 {
|
|
103
|
+
readonly schema: 'twcs/camera-intrinsics';
|
|
104
|
+
readonly version: 1;
|
|
105
|
+
/** Identifies this calibration run. A new solve produces a new id. */
|
|
106
|
+
readonly profileId: string;
|
|
107
|
+
/** The operator-assigned camera name, such as `stage-left`. Stable across calibration runs. */
|
|
108
|
+
readonly cameraId: string;
|
|
109
|
+
/** When the calibration was solved, as an RFC 3339 timestamp in UTC. */
|
|
110
|
+
readonly calibratedAt: string;
|
|
111
|
+
/** Free text naming whatever produced the profile. Recorded for diagnostics only. */
|
|
112
|
+
readonly producer: string;
|
|
113
|
+
readonly cameraModel: CameraModel;
|
|
114
|
+
readonly image: CalibrationImage;
|
|
115
|
+
readonly intrinsics: CameraIntrinsics;
|
|
116
|
+
readonly distortion: CameraDistortion;
|
|
117
|
+
readonly capture?: CalibrationCapture;
|
|
118
|
+
readonly quality?: CalibrationQuality;
|
|
119
|
+
readonly device?: CalibrationDeviceHint;
|
|
120
|
+
}
|
|
121
|
+
export type ProfileErrorCode = 'not-an-object' | 'unsupported-schema' | 'unsupported-version' | 'missing-field' | 'unexpected-field' | 'invalid-type' | 'invalid-value' | 'out-of-range' | 'invalid-distortion' | 'inconsistent-profile' | 'forbidden-field';
|
|
122
|
+
export interface ProfileError {
|
|
123
|
+
readonly code: ProfileErrorCode;
|
|
124
|
+
/** Dotted path to the offending member, or an empty string for the document itself. */
|
|
125
|
+
readonly path: string;
|
|
126
|
+
readonly message: string;
|
|
127
|
+
}
|
|
128
|
+
export type ProfileResult = {
|
|
129
|
+
readonly ok: true;
|
|
130
|
+
readonly profile: CameraIntrinsicProfileV1;
|
|
131
|
+
} | {
|
|
132
|
+
readonly ok: false;
|
|
133
|
+
readonly error: ProfileError;
|
|
134
|
+
};
|
|
135
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/calibration/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,8EAA8E;AAC9E,MAAM,MAAM,WAAW,GAAG,SAAS,CAAC;AAEpC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IAAI,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,wBAAwB,CAAA;CAAC,GAC/D;IAAC,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAA;CAAC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The intrinsic calibration profile contract.
|
|
3
|
+
*
|
|
4
|
+
* A profile describes how one camera projects the world onto its own captured image. It says nothing
|
|
5
|
+
* about where that camera stands: the pose of a camera in a shared world frame belongs to whichever
|
|
6
|
+
* extension solves placement, and mixing the two into one document is what made the earlier
|
|
7
|
+
* `twrmc/camera-calibration` format unusable for anything but the application it came from.
|
|
8
|
+
*
|
|
9
|
+
* Camera Source owns the contract but never produces a profile. Chessboard calibration, an operator
|
|
10
|
+
* supplying JSON, or a future calibrator are all just producers of a document that passes validation.
|
|
11
|
+
*/
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/calibration/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG"}
|
package/dist/camera-source.js
CHANGED
|
@@ -17,10 +17,6 @@
|
|
|
17
17
|
license: "MPL-2.0",
|
|
18
18
|
unsandboxed: true
|
|
19
19
|
};
|
|
20
|
-
//#endregion
|
|
21
|
-
//#region config/feature-flags.ts
|
|
22
|
-
var overrides = globalThis.__TWCS_FEATURE_FLAGS__;
|
|
23
|
-
var featureFlags = Object.freeze({ calibrationProfilesV1: overrides?.calibrationProfilesV1 === true });
|
|
24
20
|
var block_definitions_default = {
|
|
25
21
|
extensionName: "Camera Source",
|
|
26
22
|
blocks: [
|
|
@@ -168,7 +164,6 @@
|
|
|
168
164
|
},
|
|
169
165
|
{
|
|
170
166
|
"opcode": "registerCameraProfile",
|
|
171
|
-
"feature": "calibrationProfilesV1",
|
|
172
167
|
"blockType": "COMMAND",
|
|
173
168
|
"text": "register camera profile [PROFILE_JSON]",
|
|
174
169
|
"arguments": { "PROFILE_JSON": {
|
|
@@ -178,7 +173,6 @@
|
|
|
178
173
|
},
|
|
179
174
|
{
|
|
180
175
|
"opcode": "forgetCameraProfile",
|
|
181
|
-
"feature": "calibrationProfilesV1",
|
|
182
176
|
"blockType": "COMMAND",
|
|
183
177
|
"text": "forget camera profile for [CAMERA_ID]",
|
|
184
178
|
"arguments": { "CAMERA_ID": {
|
|
@@ -188,7 +182,6 @@
|
|
|
188
182
|
},
|
|
189
183
|
{
|
|
190
184
|
"opcode": "cameraProfileRegistered",
|
|
191
|
-
"feature": "calibrationProfilesV1",
|
|
192
185
|
"blockType": "BOOLEAN",
|
|
193
186
|
"text": "camera [CAMERA_ID] is calibrated?",
|
|
194
187
|
"arguments": { "CAMERA_ID": {
|
|
@@ -198,7 +191,6 @@
|
|
|
198
191
|
},
|
|
199
192
|
{
|
|
200
193
|
"opcode": "cameraProfileJson",
|
|
201
|
-
"feature": "calibrationProfilesV1",
|
|
202
194
|
"blockType": "REPORTER",
|
|
203
195
|
"text": "camera profile JSON for [CAMERA_ID]",
|
|
204
196
|
"arguments": { "CAMERA_ID": {
|
|
@@ -208,21 +200,18 @@
|
|
|
208
200
|
},
|
|
209
201
|
{
|
|
210
202
|
"opcode": "cameraProfileError",
|
|
211
|
-
"feature": "calibrationProfilesV1",
|
|
212
203
|
"blockType": "REPORTER",
|
|
213
204
|
"text": "camera profile error",
|
|
214
205
|
"arguments": {}
|
|
215
206
|
},
|
|
216
207
|
{
|
|
217
208
|
"opcode": "cameraProfileErrorDetail",
|
|
218
|
-
"feature": "calibrationProfilesV1",
|
|
219
209
|
"blockType": "REPORTER",
|
|
220
210
|
"text": "camera profile error detail",
|
|
221
211
|
"arguments": {}
|
|
222
212
|
},
|
|
223
213
|
{
|
|
224
214
|
"opcode": "cameraProfileCompatibility",
|
|
225
|
-
"feature": "calibrationProfilesV1",
|
|
226
215
|
"blockType": "REPORTER",
|
|
227
216
|
"text": "camera profile compatibility for [CAMERA_ID]",
|
|
228
217
|
"arguments": { "CAMERA_ID": {
|
|
@@ -232,7 +221,6 @@
|
|
|
232
221
|
},
|
|
233
222
|
{
|
|
234
223
|
"opcode": "cameraProfileCompatibilityDetail",
|
|
235
|
-
"feature": "calibrationProfilesV1",
|
|
236
224
|
"blockType": "REPORTER",
|
|
237
225
|
"text": "camera profile compatibility detail for [CAMERA_ID]",
|
|
238
226
|
"arguments": { "CAMERA_ID": {
|
|
@@ -242,7 +230,6 @@
|
|
|
242
230
|
},
|
|
243
231
|
{
|
|
244
232
|
"opcode": "cameraProfileAdaptation",
|
|
245
|
-
"feature": "calibrationProfilesV1",
|
|
246
233
|
"blockType": "REPORTER",
|
|
247
234
|
"text": "camera profile adaptation for [CAMERA_ID]",
|
|
248
235
|
"arguments": { "CAMERA_ID": {
|
|
@@ -252,7 +239,6 @@
|
|
|
252
239
|
},
|
|
253
240
|
{
|
|
254
241
|
"opcode": "cameraProfileIntrinsicsJson",
|
|
255
|
-
"feature": "calibrationProfilesV1",
|
|
256
242
|
"blockType": "REPORTER",
|
|
257
243
|
"text": "camera intrinsics JSON for [CAMERA_ID]",
|
|
258
244
|
"arguments": { "CAMERA_ID": {
|
|
@@ -262,7 +248,6 @@
|
|
|
262
248
|
},
|
|
263
249
|
{
|
|
264
250
|
"opcode": "cameraConditionsJson",
|
|
265
|
-
"feature": "calibrationProfilesV1",
|
|
266
251
|
"blockType": "REPORTER",
|
|
267
252
|
"text": "camera conditions JSON for [CAMERA_ID]",
|
|
268
253
|
"arguments": { "CAMERA_ID": {
|
|
@@ -272,7 +257,6 @@
|
|
|
272
257
|
},
|
|
273
258
|
{
|
|
274
259
|
"opcode": "cameraConditionsGeneration",
|
|
275
|
-
"feature": "calibrationProfilesV1",
|
|
276
260
|
"blockType": "REPORTER",
|
|
277
261
|
"text": "camera conditions generation for [CAMERA_ID]",
|
|
278
262
|
"arguments": { "CAMERA_ID": {
|
|
@@ -1038,13 +1022,31 @@
|
|
|
1038
1022
|
}
|
|
1039
1023
|
};
|
|
1040
1024
|
//#endregion
|
|
1025
|
+
//#region src/runtime.ts
|
|
1026
|
+
/**
|
|
1027
|
+
* Where the extension instance puts itself on the VM runtime.
|
|
1028
|
+
*
|
|
1029
|
+
* Present as soon as the extension is registered. Absent means Camera Source is not loaded, which a
|
|
1030
|
+
* consumer has to handle whatever else it does.
|
|
1031
|
+
*/
|
|
1032
|
+
var cameraSourceRuntimeKey = "ext_kubohiroyacamerasource";
|
|
1033
|
+
/**
|
|
1034
|
+
* Where the versioned capability sits, when the build publishing it has that path enabled.
|
|
1035
|
+
*
|
|
1036
|
+
* Separate from `cameraSourceRuntimeKey` on purpose. The extension key is present as soon as Camera
|
|
1037
|
+
* Source is registered; this one appears only when the calibration profile contract is switched on.
|
|
1038
|
+
* A consumer can therefore tell "not loaded" from "loaded, and not offering profiles", and neither
|
|
1039
|
+
* has to be reported as the other.
|
|
1040
|
+
*/
|
|
1041
|
+
var cameraSourceCapabilityKey = "kubohiroyaCameraSourceCapability";
|
|
1042
|
+
//#endregion
|
|
1041
1043
|
//#region src/runtime-capability.ts
|
|
1042
|
-
var
|
|
1044
|
+
var runtimeCapabilityVersion = 1;
|
|
1043
1045
|
function createRuntimeCapability(host) {
|
|
1044
1046
|
const capability = {
|
|
1045
|
-
version:
|
|
1047
|
+
version: runtimeCapabilityVersion,
|
|
1046
1048
|
requireVersion(version) {
|
|
1047
|
-
if (version !==
|
|
1049
|
+
if (version !== runtimeCapabilityVersion) throw new Error(`Unsupported Camera Source runtime capability version: ${version}; this build provides ${runtimeCapabilityVersion}.`);
|
|
1048
1050
|
return capability;
|
|
1049
1051
|
},
|
|
1050
1052
|
registerProfile: (document) => host.registerProfile(document),
|
|
@@ -1083,15 +1085,6 @@
|
|
|
1083
1085
|
return flip === "vertical" || flip === "both";
|
|
1084
1086
|
}
|
|
1085
1087
|
//#endregion
|
|
1086
|
-
//#region src/runtime.ts
|
|
1087
|
-
/**
|
|
1088
|
-
* Where the extension instance puts itself on the VM runtime.
|
|
1089
|
-
*
|
|
1090
|
-
* Present as soon as the extension is registered. Absent means Camera Source is not loaded, which a
|
|
1091
|
-
* consumer has to handle whatever else it does.
|
|
1092
|
-
*/
|
|
1093
|
-
var cameraSourceRuntimeKey = "ext_kubohiroyacamerasource";
|
|
1094
|
-
//#endregion
|
|
1095
1088
|
//#region src/video-preview.ts
|
|
1096
1089
|
var videoLayer = "video";
|
|
1097
1090
|
var haveCurrentData = 2;
|
|
@@ -1323,12 +1316,11 @@
|
|
|
1323
1316
|
this.generations = /* @__PURE__ */ new Map();
|
|
1324
1317
|
this.lastConditions = /* @__PURE__ */ new Map();
|
|
1325
1318
|
this.assessments = /* @__PURE__ */ new Map();
|
|
1326
|
-
this.calibrationEnabled = featureFlags.calibrationProfilesV1;
|
|
1327
1319
|
this.devices = [];
|
|
1328
1320
|
this.dispose = () => {
|
|
1329
1321
|
this.stopAllCameras();
|
|
1330
1322
|
const runtime = Scratch.vm.runtime;
|
|
1331
|
-
if (runtime["kubohiroyaCameraSourceCapability"] === this.capability) delete runtime[
|
|
1323
|
+
if (runtime["kubohiroyaCameraSourceCapability"] === this.capability) delete runtime[cameraSourceCapabilityKey];
|
|
1332
1324
|
Scratch.vm.runtime.off?.("PROJECT_STOP_ALL", this.handleProjectBoundary);
|
|
1333
1325
|
Scratch.vm.runtime.off?.("PROJECT_LOADED", this.handleProjectBoundary);
|
|
1334
1326
|
Scratch.vm.runtime.off?.("RUNTIME_DISPOSED", this.dispose);
|
|
@@ -1338,7 +1330,7 @@
|
|
|
1338
1330
|
this.profileError = void 0;
|
|
1339
1331
|
};
|
|
1340
1332
|
Scratch.vm.runtime[cameraSourceRuntimeKey] = this;
|
|
1341
|
-
this.capability =
|
|
1333
|
+
this.capability = createRuntimeCapability({
|
|
1342
1334
|
registerProfile: (document) => this.profiles.register(document),
|
|
1343
1335
|
forgetProfile: (cameraId) => this.profiles.forget(cameraId),
|
|
1344
1336
|
profileFor: (cameraId) => this.profiles.get(cameraId),
|
|
@@ -1349,8 +1341,8 @@
|
|
|
1349
1341
|
intrinsicsFor: (cameraId) => this.intrinsicsOf(cameraId),
|
|
1350
1342
|
conditionsFor: (cameraId) => this.conditionsOf(cameraId),
|
|
1351
1343
|
conditionsGeneration: (cameraId) => this.generationOf(cameraId)
|
|
1352
|
-
})
|
|
1353
|
-
|
|
1344
|
+
});
|
|
1345
|
+
Scratch.vm.runtime[cameraSourceCapabilityKey] = this.capability;
|
|
1354
1346
|
Scratch.vm.runtime.on?.("PROJECT_STOP_ALL", this.handleProjectBoundary);
|
|
1355
1347
|
Scratch.vm.runtime.on?.("PROJECT_LOADED", this.handleProjectBoundary);
|
|
1356
1348
|
Scratch.vm.runtime.on?.("RUNTIME_DISPOSED", this.dispose);
|
|
@@ -1359,7 +1351,7 @@
|
|
|
1359
1351
|
return {
|
|
1360
1352
|
id: extensionConfig.id,
|
|
1361
1353
|
name: Scratch.translate(block_definitions_default.extensionName),
|
|
1362
|
-
blocks: blockDefinitions.
|
|
1354
|
+
blocks: blockDefinitions.map((block) => this.toScratchBlock(block)),
|
|
1363
1355
|
menus: Object.fromEntries(Object.entries(menuDefinitions).map(([id, menu]) => [id, {
|
|
1364
1356
|
acceptReporters: menu.acceptReporters,
|
|
1365
1357
|
items: [...menu.items]
|
package/dist/flip.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpers over the published `Flip` vocabulary.
|
|
3
|
+
*
|
|
4
|
+
* The type itself lives in the runtime contract, because consumers read it off a frame source and
|
|
5
|
+
* should not be re-declaring it. What stays here is the reasoning a caller needs and the small
|
|
6
|
+
* operations the extension performs on it.
|
|
7
|
+
*
|
|
8
|
+
* The vocabulary replaced a `mirrored: boolean`, which could not say which axis, and on a frame
|
|
9
|
+
* source could not say whether it described the pixels or the way they were being shown. Those are
|
|
10
|
+
* different facts with different consequences: a consumer that reads a display choice as a pixel
|
|
11
|
+
* state feeds flipped coordinates into a solve, and the pose it gets back is a left-right
|
|
12
|
+
* reflection whose reprojection error stays small.
|
|
13
|
+
*/
|
|
14
|
+
import type { Flip } from './runtime.js';
|
|
15
|
+
export type { Flip };
|
|
16
|
+
export declare const FLIPS: readonly Flip[];
|
|
17
|
+
export declare function isFlip(value: unknown): value is Flip;
|
|
18
|
+
/** Reads a flip, accepting the boolean the older API used for left-right. */
|
|
19
|
+
export declare function toFlip(value: unknown, fallback?: Flip): Flip;
|
|
20
|
+
export declare function flipsHorizontally(flip: Flip): boolean;
|
|
21
|
+
export declare function flipsVertically(flip: Flip): boolean;
|
|
22
|
+
/** Combines two flips; flipping the same axis twice returns it to none. */
|
|
23
|
+
export declare function combineFlips(left: Flip, right: Flip): Flip;
|
|
24
|
+
//# sourceMappingURL=flip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flip.d.ts","sourceRoot":"","sources":["../src/flip.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,cAAc,CAAC;AAEvC,YAAY,EAAC,IAAI,EAAC,CAAC;AAEnB,eAAO,MAAM,KAAK,EAAE,SAAS,IAAI,EAA+C,CAAC;AAEjF,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,IAAI,CAEpD;AAED,6EAA6E;AAC7E,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,GAAE,IAAa,GAAG,IAAI,CAKpE;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAErD;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAEnD;AAED,2EAA2E;AAC3E,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,GAAG,IAAI,CAO1D"}
|
package/dist/flip.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export const FLIPS = ['none', 'horizontal', 'vertical', 'both'];
|
|
2
|
+
export function isFlip(value) {
|
|
3
|
+
return typeof value === 'string' && FLIPS.includes(value);
|
|
4
|
+
}
|
|
5
|
+
/** Reads a flip, accepting the boolean the older API used for left-right. */
|
|
6
|
+
export function toFlip(value, fallback = 'none') {
|
|
7
|
+
if (isFlip(value))
|
|
8
|
+
return value;
|
|
9
|
+
if (value === true)
|
|
10
|
+
return 'horizontal';
|
|
11
|
+
if (value === false)
|
|
12
|
+
return 'none';
|
|
13
|
+
return fallback;
|
|
14
|
+
}
|
|
15
|
+
export function flipsHorizontally(flip) {
|
|
16
|
+
return flip === 'horizontal' || flip === 'both';
|
|
17
|
+
}
|
|
18
|
+
export function flipsVertically(flip) {
|
|
19
|
+
return flip === 'vertical' || flip === 'both';
|
|
20
|
+
}
|
|
21
|
+
/** Combines two flips; flipping the same axis twice returns it to none. */
|
|
22
|
+
export function combineFlips(left, right) {
|
|
23
|
+
const horizontal = flipsHorizontally(left) !== flipsHorizontally(right);
|
|
24
|
+
const vertical = flipsVertically(left) !== flipsVertically(right);
|
|
25
|
+
if (horizontal && vertical)
|
|
26
|
+
return 'both';
|
|
27
|
+
if (horizontal)
|
|
28
|
+
return 'horizontal';
|
|
29
|
+
if (vertical)
|
|
30
|
+
return 'vertical';
|
|
31
|
+
return 'none';
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=flip.js.map
|
package/dist/flip.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flip.js","sourceRoot":"","sources":["../src/flip.ts"],"names":[],"mappings":"AAiBA,MAAM,CAAC,MAAM,KAAK,GAAoB,CAAC,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;AAEjF,MAAM,UAAU,MAAM,CAAC,KAAc;IACnC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAK,KAA2B,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACnF,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,MAAM,CAAC,KAAc,EAAE,WAAiB,MAAM;IAC5D,IAAI,MAAM,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAChC,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,YAAY,CAAC;IACxC,IAAI,KAAK,KAAK,KAAK;QAAE,OAAO,MAAM,CAAC;IACnC,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,IAAU;IAC1C,OAAO,IAAI,KAAK,YAAY,IAAI,IAAI,KAAK,MAAM,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,IAAU;IACxC,OAAO,IAAI,KAAK,UAAU,IAAI,IAAI,KAAK,MAAM,CAAC;AAChD,CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,YAAY,CAAC,IAAU,EAAE,KAAW;IAClD,MAAM,UAAU,GAAG,iBAAiB,CAAC,IAAI,CAAC,KAAK,iBAAiB,CAAC,KAAK,CAAC,CAAC;IACxE,MAAM,QAAQ,GAAG,eAAe,CAAC,IAAI,CAAC,KAAK,eAAe,CAAC,KAAK,CAAC,CAAC;IAClE,IAAI,UAAU,IAAI,QAAQ;QAAE,OAAO,MAAM,CAAC;IAC1C,IAAI,UAAU;QAAE,OAAO,YAAY,CAAC;IACpC,IAAI,QAAQ;QAAE,OAAO,UAAU,CAAC;IAChC,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What other extensions may use without going through blocks.
|
|
3
|
+
*
|
|
4
|
+
* Published under a versioned key rather than as the extension object itself,
|
|
5
|
+
* so a consumer states the contract it was written against and is refused
|
|
6
|
+
* clearly instead of finding a method missing at the worst moment.
|
|
7
|
+
*/
|
|
8
|
+
import type { ProfileAdaptation, UsableIntrinsics } from './calibration/adaptation.js';
|
|
9
|
+
import type { CompatibilityReport } from './calibration/compatibility.js';
|
|
10
|
+
import type { CameraConditions } from './calibration/conditions.js';
|
|
11
|
+
import type { CameraIntrinsicProfileV1, ProfileResult } from './calibration/types.js';
|
|
12
|
+
export { cameraSourceCapabilityKey as runtimeCapabilityKey, cameraSourceCapabilityVersion as runtimeCapabilityVersion } from './runtime.js';
|
|
13
|
+
declare const runtimeCapabilityVersion: 1;
|
|
14
|
+
export interface CameraProfileView {
|
|
15
|
+
/** The document as stored. For showing an operator or writing back out, not for projecting with. */
|
|
16
|
+
readonly profile: CameraIntrinsicProfileV1;
|
|
17
|
+
readonly compatibility: CompatibilityReport;
|
|
18
|
+
/** How the stored numbers would be re-expressed for this frame size, whether or not they may be used. */
|
|
19
|
+
readonly adaptation: ProfileAdaptation;
|
|
20
|
+
/**
|
|
21
|
+
* The numbers that may be used, absent when none may be.
|
|
22
|
+
*
|
|
23
|
+
* A consumer that reaches for `profile.intrinsics` or `adaptation.intrinsics` instead is reading
|
|
24
|
+
* past the question of whether this calibration belongs to this camera, and the wrong answer does
|
|
25
|
+
* not look wrong: it projects, and returns geometry that reads as a slightly different pose.
|
|
26
|
+
*/
|
|
27
|
+
readonly usable?: UsableIntrinsics;
|
|
28
|
+
}
|
|
29
|
+
export interface CameraSourceCapabilityV1 {
|
|
30
|
+
readonly version: typeof runtimeCapabilityVersion;
|
|
31
|
+
requireVersion(version: number): CameraSourceCapabilityV1;
|
|
32
|
+
/** Stores a profile document, whatever produced it. */
|
|
33
|
+
registerProfile(document: unknown): ProfileResult;
|
|
34
|
+
forgetProfile(cameraId: string): boolean;
|
|
35
|
+
profileFor(cameraId: string): CameraIntrinsicProfileV1 | undefined;
|
|
36
|
+
calibratedCameras(): string[];
|
|
37
|
+
/**
|
|
38
|
+
* The profile judged against how the camera is configured right now.
|
|
39
|
+
*
|
|
40
|
+
* Absent when the camera has never been calibrated. That is an ordinary state and not a failure:
|
|
41
|
+
* reporting it as one would leave every consumer deciding which failures are real, and the safe
|
|
42
|
+
* reading of a failure is to stop, which is the wrong response to "nobody has calibrated this
|
|
43
|
+
* camera yet".
|
|
44
|
+
*/
|
|
45
|
+
assessProfile(cameraId: string): CameraProfileView | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* The intrinsics to project the current frames with, or undefined when there are none to use.
|
|
48
|
+
*
|
|
49
|
+
* The short way to ask the only question a consumer usually has. `assessProfile` answers the same
|
|
50
|
+
* thing in its `usable` member, alongside the reasons.
|
|
51
|
+
*/
|
|
52
|
+
intrinsicsFor(cameraId: string): UsableIntrinsics | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* What the track reports about itself, read only.
|
|
55
|
+
*
|
|
56
|
+
* Reading, never setting. Changing a shared camera's configuration from one
|
|
57
|
+
* consumer would silently change what every other consumer is recording.
|
|
58
|
+
*/
|
|
59
|
+
conditionsFor(cameraId: string): CameraConditions;
|
|
60
|
+
/**
|
|
61
|
+
* Increments whenever something that affects the geometry changes.
|
|
62
|
+
*
|
|
63
|
+
* A consumer holding a result derived from a profile can compare one integer
|
|
64
|
+
* instead of re-checking every condition, and knows to discard what it cached
|
|
65
|
+
* when the number moves.
|
|
66
|
+
*/
|
|
67
|
+
conditionsGeneration(cameraId: string): number;
|
|
68
|
+
}
|
|
69
|
+
export declare function createRuntimeCapability(host: Omit<CameraSourceCapabilityV1, 'version' | 'requireVersion'>): CameraSourceCapabilityV1;
|
|
70
|
+
//# sourceMappingURL=runtime-capability.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-capability.d.ts","sourceRoot":"","sources":["../src/runtime-capability.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAC,iBAAiB,EAAE,gBAAgB,EAAC,MAAM,6BAA6B,CAAC;AACrF,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,gCAAgC,CAAC;AACxE,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,6BAA6B,CAAC;AAClE,OAAO,KAAK,EAAC,wBAAwB,EAAE,aA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,wBAAwB,CAqB1B"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Defined in the published entry rather than here, so the name a consumer imports and the name this
|
|
2
|
+
// extension publishes under cannot drift apart into two string literals that agree by inspection.
|
|
3
|
+
export { cameraSourceCapabilityKey as runtimeCapabilityKey, cameraSourceCapabilityVersion as runtimeCapabilityVersion } from './runtime.js';
|
|
4
|
+
import { cameraSourceCapabilityVersion } from './runtime.js';
|
|
5
|
+
const runtimeCapabilityVersion = cameraSourceCapabilityVersion;
|
|
6
|
+
export function createRuntimeCapability(host) {
|
|
7
|
+
const capability = {
|
|
8
|
+
version: runtimeCapabilityVersion,
|
|
9
|
+
requireVersion(version) {
|
|
10
|
+
if (version !== runtimeCapabilityVersion) {
|
|
11
|
+
throw new Error(`Unsupported Camera Source runtime capability version: ${version}; this build provides ${runtimeCapabilityVersion}.`);
|
|
12
|
+
}
|
|
13
|
+
return capability;
|
|
14
|
+
},
|
|
15
|
+
registerProfile: (document) => host.registerProfile(document),
|
|
16
|
+
forgetProfile: (cameraId) => host.forgetProfile(cameraId),
|
|
17
|
+
profileFor: (cameraId) => host.profileFor(cameraId),
|
|
18
|
+
calibratedCameras: () => host.calibratedCameras(),
|
|
19
|
+
assessProfile: (cameraId) => host.assessProfile(cameraId),
|
|
20
|
+
intrinsicsFor: (cameraId) => host.intrinsicsFor(cameraId),
|
|
21
|
+
conditionsFor: (cameraId) => host.conditionsFor(cameraId),
|
|
22
|
+
conditionsGeneration: (cameraId) => host.conditionsGeneration(cameraId)
|
|
23
|
+
};
|
|
24
|
+
return Object.freeze(capability);
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=runtime-capability.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-capability.js","sourceRoot":"","sources":["../src/runtime-capability.ts"],"names":[],"mappings":"AAYA,oGAAoG;AACpG,kGAAkG;AAClG,OAAO,EACL,yBAAyB,IAAI,oBAAoB,EACjD,6BAA6B,IAAI,w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ExtensionId = "kubohiroyacamerasource";
|
|
|
19
19
|
* consumer has to handle whatever else it does.
|
|
20
20
|
*/
|
|
21
21
|
export declare const cameraSourceRuntimeKey = "ext_kubohiroyacamerasource";
|
|
22
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* Where the versioned capability sits, when the build publishing it has that path enabled.
|
|
24
|
+
*
|
|
25
|
+
* Separate from `cameraSourceRuntimeKey` on purpose. The extension key is present as soon as Camera
|
|
26
|
+
* Source is registered; this one appears only when the calibration profile contract is switched on.
|
|
27
|
+
* A consumer can therefore tell "not loaded" from "loaded, and not offering profiles", and neither
|
|
28
|
+
* has to be reported as the other.
|
|
29
|
+
*/
|
|
23
30
|
export declare const cameraSourceCapabilityKey = "kubohiroyaCameraSourceCapability";
|
|
31
|
+
/** The capability version this build implements. `requireVersion` refuses any other. */
|
|
32
|
+
export declare const cameraSourceCapabilityVersion: 1;
|
|
24
33
|
/**
|
|
25
34
|
* Which way an image has been turned over.
|
|
26
35
|
*
|
|
@@ -71,6 +80,32 @@ export interface CameraLease {
|
|
|
71
80
|
export interface CameraSourceRuntime {
|
|
72
81
|
acquireCamera(options?: CameraAcquireOptions): Promise<CameraLease>;
|
|
73
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* The profile contract, re-exported so a consumer states it rather than restating it.
|
|
85
|
+
*
|
|
86
|
+
* These are declarations only and cost a consumer nothing at run time. They are published because a
|
|
87
|
+
* hand-written copy is checked against nothing: `turbowarp-camera-calibration` wrote its own copy of
|
|
88
|
+
* the registry, named a method this extension does not have, and every attempt to publish a profile
|
|
89
|
+
* failed for a reason unrelated to the message it produced. Its type-check passed throughout.
|
|
90
|
+
*/
|
|
91
|
+
export type { CameraProfileView, CameraSourceCapabilityV1 } from './runtime-capability.js';
|
|
92
|
+
export type { CalibrationCapture, CalibrationDeviceHint, CalibrationImage, CalibrationQuality, CameraDistortion, CameraIntrinsicProfileV1, CameraIntrinsics, CameraModel, DistortionModel, ProfileError, ProfileErrorCode, ProfileResult } from './calibration/types.js';
|
|
93
|
+
export type { AdaptationCode, AdaptationState, ProfileAdaptation, UsableIntrinsics } from './calibration/adaptation.js';
|
|
94
|
+
export type { CompatibilityCode, CompatibilityFinding, CompatibilityReport, CompatibilityState, FindingState } from './calibration/compatibility.js';
|
|
95
|
+
export type { CameraConditions } from './calibration/conditions.js';
|
|
96
|
+
import type { CameraSourceCapabilityV1 } from './runtime-capability.js';
|
|
74
97
|
/** Narrows a runtime value to the Camera Source surface, so a missing extension reads as absent. */
|
|
75
98
|
export declare function readCameraSourceRuntime(runtime: unknown): CameraSourceRuntime | undefined;
|
|
99
|
+
/**
|
|
100
|
+
* Narrows a runtime value to the profile capability, or reports it as unavailable.
|
|
101
|
+
*
|
|
102
|
+
* Undefined means one of two things a consumer usually handles the same way: Camera Source is not
|
|
103
|
+
* loaded, or it is loaded with the profile contract switched off. `readCameraSourceRuntime` is what
|
|
104
|
+
* separates them when the difference matters -- a consumer that can still share a camera but cannot
|
|
105
|
+
* ask about calibration should say that, rather than reporting the extension as missing.
|
|
106
|
+
*
|
|
107
|
+
* A version this build does not implement is a third thing again, and not an absence: the capability
|
|
108
|
+
* is returned, and `requireVersion` refuses out loud when asked for a version it cannot honour.
|
|
109
|
+
*/
|
|
110
|
+
export declare function readCameraSourceCapability(runtime: unknown): CameraSourceCapabilityV1 | undefined;
|
|
76
111
|
//# sourceMappingURL=runtime.d.ts.map
|
package/dist/runtime.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,0FAA0F;AAC1F,eAAO,MAAM,uBAAuB,2BAA2B,CAAC;AAEhE;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,+BAA+B,CAAC;AAEnE
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;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Y,EACV,iBAAiB,EACjB,wBAAwB,EACzB,MAAM,yBAAyB,CAAC;AAEjC,YAAY,EACV,kBAAkB,EAClB,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,wBAAwB,EACxB,gBAAgB,EAChB,WAAW,EACX,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACd,MAAM,wBAAwB,CAAC;AAEhC,YAAY,EACV,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,6BAA6B,CAAC;AAErC,YAAY,EACV,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EAClB,YAAY,EACb,MAAM,gCAAgC,CAAC;AAExC,YAAY,EAAC,gBAAgB,EAAC,MAAM,6BAA6B,CAAC;AAElE,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,yBAAyB,CAAC;AAEtE,oGAAoG;AACpG,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,GAAG,mBAAmB,GAAG,SAAS,CAMzF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,OAAO,GACf,wBAAwB,GAAG,SAAS,CAMtC"}
|
package/dist/runtime.js
CHANGED
|
@@ -19,8 +19,17 @@ export const cameraSourceExtensionId = 'kubohiroyacamerasource';
|
|
|
19
19
|
* consumer has to handle whatever else it does.
|
|
20
20
|
*/
|
|
21
21
|
export const cameraSourceRuntimeKey = 'ext_kubohiroyacamerasource';
|
|
22
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* Where the versioned capability sits, when the build publishing it has that path enabled.
|
|
24
|
+
*
|
|
25
|
+
* Separate from `cameraSourceRuntimeKey` on purpose. The extension key is present as soon as Camera
|
|
26
|
+
* Source is registered; this one appears only when the calibration profile contract is switched on.
|
|
27
|
+
* A consumer can therefore tell "not loaded" from "loaded, and not offering profiles", and neither
|
|
28
|
+
* has to be reported as the other.
|
|
29
|
+
*/
|
|
23
30
|
export const cameraSourceCapabilityKey = 'kubohiroyaCameraSourceCapability';
|
|
31
|
+
/** The capability version this build implements. `requireVersion` refuses any other. */
|
|
32
|
+
export const cameraSourceCapabilityVersion = 1;
|
|
24
33
|
/** Narrows a runtime value to the Camera Source surface, so a missing extension reads as absent. */
|
|
25
34
|
export function readCameraSourceRuntime(runtime) {
|
|
26
35
|
if (typeof runtime !== 'object' || runtime === null)
|
|
@@ -31,4 +40,24 @@ export function readCameraSourceRuntime(runtime) {
|
|
|
31
40
|
const { acquireCamera } = candidate;
|
|
32
41
|
return typeof acquireCamera === 'function' ? candidate : undefined;
|
|
33
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Narrows a runtime value to the profile capability, or reports it as unavailable.
|
|
45
|
+
*
|
|
46
|
+
* Undefined means one of two things a consumer usually handles the same way: Camera Source is not
|
|
47
|
+
* loaded, or it is loaded with the profile contract switched off. `readCameraSourceRuntime` is what
|
|
48
|
+
* separates them when the difference matters -- a consumer that can still share a camera but cannot
|
|
49
|
+
* ask about calibration should say that, rather than reporting the extension as missing.
|
|
50
|
+
*
|
|
51
|
+
* A version this build does not implement is a third thing again, and not an absence: the capability
|
|
52
|
+
* is returned, and `requireVersion` refuses out loud when asked for a version it cannot honour.
|
|
53
|
+
*/
|
|
54
|
+
export function readCameraSourceCapability(runtime) {
|
|
55
|
+
if (typeof runtime !== 'object' || runtime === null)
|
|
56
|
+
return undefined;
|
|
57
|
+
const candidate = runtime[cameraSourceCapabilityKey];
|
|
58
|
+
if (typeof candidate !== 'object' || candidate === null)
|
|
59
|
+
return undefined;
|
|
60
|
+
const { requireVersion } = candidate;
|
|
61
|
+
return typeof requireVersion === 'function' ? candidate : undefined;
|
|
62
|
+
}
|
|
34
63
|
//# sourceMappingURL=runtime.js.map
|
package/dist/runtime.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA;;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,KAAK,IAAI;QAAE,OAAO,SAAS,CAAC;IAC1E,MAAM,EAAC,cAAc,EAAC,GAAG,SAAuC,CAAC;IACjE,OAAO,OAAO,cAAc,KAAK,UAAU,CAAC,CAAC,CAAE,SAAsC,CAAC,CAAC,CAAC,SAAS,CAAC;AACpG,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubohiroya/turbowarp-camera-source",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"author": "Hiroya Kubo <hiroya@cuc.ac.jp>",
|
|
5
5
|
"description": "A TurboWarp capability extension for sharing one MediaDevices camera stream across extensions.",
|
|
6
6
|
"type": "module",
|