@kubohiroya/turbowarp-camera-source 0.5.0 → 0.7.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.
@@ -2,6 +2,26 @@
2
2
  "formatVersion": 1,
3
3
  "id": "kubohiroyacamerasource",
4
4
  "blocks": [
5
+ {
6
+ "opcode": "cameraConditionsGeneration",
7
+ "blockType": "REPORTER",
8
+ "arguments": [
9
+ {
10
+ "id": "CAMERA_ID",
11
+ "type": "STRING"
12
+ }
13
+ ]
14
+ },
15
+ {
16
+ "opcode": "cameraConditionsJson",
17
+ "blockType": "REPORTER",
18
+ "arguments": [
19
+ {
20
+ "id": "CAMERA_ID",
21
+ "type": "STRING"
22
+ }
23
+ ]
24
+ },
5
25
  {
6
26
  "opcode": "cameraDeviceCount",
7
27
  "blockType": "REPORTER",
@@ -37,6 +57,26 @@
37
57
  }
38
58
  ]
39
59
  },
60
+ {
61
+ "opcode": "cameraError",
62
+ "blockType": "REPORTER",
63
+ "arguments": [
64
+ {
65
+ "id": "CAMERA_ID",
66
+ "type": "STRING"
67
+ }
68
+ ]
69
+ },
70
+ {
71
+ "opcode": "cameraErrorCode",
72
+ "blockType": "REPORTER",
73
+ "arguments": [
74
+ {
75
+ "id": "CAMERA_ID",
76
+ "type": "STRING"
77
+ }
78
+ ]
79
+ },
40
80
  {
41
81
  "opcode": "cameraFrameHeight",
42
82
  "blockType": "REPORTER",
@@ -67,6 +107,86 @@
67
107
  }
68
108
  ]
69
109
  },
110
+ {
111
+ "opcode": "cameraProfileAdaptation",
112
+ "blockType": "REPORTER",
113
+ "arguments": [
114
+ {
115
+ "id": "CAMERA_ID",
116
+ "type": "STRING"
117
+ }
118
+ ]
119
+ },
120
+ {
121
+ "opcode": "cameraProfileCompatibility",
122
+ "blockType": "REPORTER",
123
+ "arguments": [
124
+ {
125
+ "id": "CAMERA_ID",
126
+ "type": "STRING"
127
+ }
128
+ ]
129
+ },
130
+ {
131
+ "opcode": "cameraProfileCompatibilityDetail",
132
+ "blockType": "REPORTER",
133
+ "arguments": [
134
+ {
135
+ "id": "CAMERA_ID",
136
+ "type": "STRING"
137
+ }
138
+ ]
139
+ },
140
+ {
141
+ "opcode": "cameraProfileError",
142
+ "blockType": "REPORTER",
143
+ "arguments": []
144
+ },
145
+ {
146
+ "opcode": "cameraProfileErrorDetail",
147
+ "blockType": "REPORTER",
148
+ "arguments": []
149
+ },
150
+ {
151
+ "opcode": "cameraProfileIntrinsicsJson",
152
+ "blockType": "REPORTER",
153
+ "arguments": [
154
+ {
155
+ "id": "CAMERA_ID",
156
+ "type": "STRING"
157
+ }
158
+ ]
159
+ },
160
+ {
161
+ "opcode": "cameraProfileJson",
162
+ "blockType": "REPORTER",
163
+ "arguments": [
164
+ {
165
+ "id": "CAMERA_ID",
166
+ "type": "STRING"
167
+ }
168
+ ]
169
+ },
170
+ {
171
+ "opcode": "cameraProfileRegistered",
172
+ "blockType": "BOOLEAN",
173
+ "arguments": [
174
+ {
175
+ "id": "CAMERA_ID",
176
+ "type": "STRING"
177
+ }
178
+ ]
179
+ },
180
+ {
181
+ "opcode": "forgetCameraProfile",
182
+ "blockType": "COMMAND",
183
+ "arguments": [
184
+ {
185
+ "id": "CAMERA_ID",
186
+ "type": "STRING"
187
+ }
188
+ ]
189
+ },
70
190
  {
71
191
  "opcode": "hideCameraPreview",
72
192
  "blockType": "COMMAND",
@@ -92,6 +212,16 @@
92
212
  "blockType": "COMMAND",
93
213
  "arguments": []
94
214
  },
215
+ {
216
+ "opcode": "registerCameraProfile",
217
+ "blockType": "COMMAND",
218
+ "arguments": [
219
+ {
220
+ "id": "PROFILE_JSON",
221
+ "type": "STRING"
222
+ }
223
+ ]
224
+ },
95
225
  {
96
226
  "opcode": "showCameraPreview",
97
227
  "blockType": "COMMAND",
@@ -101,8 +231,9 @@
101
231
  "type": "STRING"
102
232
  },
103
233
  {
104
- "id": "MIRRORED",
105
- "type": "STRING"
234
+ "id": "PREVIEW_FLIP",
235
+ "type": "STRING",
236
+ "menu": "flips"
106
237
  }
107
238
  ]
108
239
  },
@@ -131,5 +262,10 @@
131
262
  ]
132
263
  }
133
264
  ],
134
- "menus": []
265
+ "menus": [
266
+ {
267
+ "id": "flips",
268
+ "acceptReporters": true
269
+ }
270
+ ]
135
271
  }
@@ -0,0 +1,76 @@
1
+ /**
2
+ * The contract other extensions use to share a camera with this one.
3
+ *
4
+ * Published as its own entry point so a consumer states what it expects instead of re-declaring it.
5
+ * A hand-written copy of an interface compiles perfectly against nothing: when the shape here
6
+ * changes, the copy keeps type-checking in its own repository and fails at runtime in a browser,
7
+ * which is the worst order to find out. Importing these declarations moves that failure to the
8
+ * consumer's build.
9
+ *
10
+ * This module holds no logic and pulls in none of the extension, so importing it costs a consumer
11
+ * nothing at runtime beyond the three constants below.
12
+ */
13
+ /** The extension ID, as it appears in block opcodes and in a project's extension list. */
14
+ export declare const cameraSourceExtensionId = "kubohiroyacamerasource";
15
+ /**
16
+ * Where the extension instance puts itself on the VM runtime.
17
+ *
18
+ * Present as soon as the extension is registered. Absent means Camera Source is not loaded, which a
19
+ * consumer has to handle whatever else it does.
20
+ */
21
+ export declare const cameraSourceRuntimeKey = "ext_kubohiroyacamerasource";
22
+ /** Where the versioned capability sits, when the build publishing it has that path enabled. */
23
+ export declare const cameraSourceCapabilityKey = "kubohiroyaCameraSourceCapability";
24
+ /**
25
+ * Which way an image has been turned over.
26
+ *
27
+ * `horizontal` is the left-right mirror, matching `cv::flip` with a flip code of 1, ffmpeg's
28
+ * `hflip` and CSS `scaleX(-1)`. Rotation is deliberately not folded in: a portrait capture is a
29
+ * rotation and not a flip, and once both exist their order matters.
30
+ */
31
+ export type Flip = 'none' | 'horizontal' | 'vertical' | 'both';
32
+ export interface CameraAcquireOptions {
33
+ /** Free text naming the caller. Appears in diagnostics; never used to decide anything. */
34
+ owner?: string;
35
+ /** The role name of the stream, such as `pose` or `qr`. Callers naming the same one share it. */
36
+ cameraId?: string;
37
+ deviceId?: string;
38
+ video?: MediaTrackConstraints | boolean;
39
+ /** How this consumer wants the stage preview drawn. Only meaningful together with `preview`. */
40
+ previewFlip?: Flip;
41
+ preview?: boolean;
42
+ }
43
+ export interface CameraFrameSource {
44
+ readonly kind: 'video';
45
+ readonly element: HTMLVideoElement;
46
+ readonly width: number;
47
+ readonly height: number;
48
+ /**
49
+ * How the stage preview is being drawn, which says nothing about the pixels.
50
+ *
51
+ * The frames behind it are always the ones the camera captured: drawing a preview turned over is
52
+ * a rendering transform and never reaches them. A consumer that reads this as a statement about
53
+ * the image and flips its coordinates to compensate feeds a solve reflected input, and the pose
54
+ * that comes back is a left-right reflection whose reprojection error stays small.
55
+ *
56
+ * Read it when drawing something that sits next to the preview and should match it.
57
+ */
58
+ readonly previewFlip: Flip;
59
+ readonly deviceId: string;
60
+ }
61
+ export interface CameraLease {
62
+ getFrameSource(): CameraFrameSource;
63
+ release(): Promise<void>;
64
+ }
65
+ /**
66
+ * What `Scratch.vm.runtime[cameraSourceRuntimeKey]` offers.
67
+ *
68
+ * Only the members a sharing consumer needs are named here. The extension instance carries its
69
+ * block methods as well, but those are the block surface and not a contract between extensions.
70
+ */
71
+ export interface CameraSourceRuntime {
72
+ acquireCamera(options?: CameraAcquireOptions): Promise<CameraLease>;
73
+ }
74
+ /** Narrows a runtime value to the Camera Source surface, so a missing extension reads as absent. */
75
+ export declare function readCameraSourceRuntime(runtime: unknown): CameraSourceRuntime | undefined;
76
+ //# sourceMappingURL=runtime.d.ts.map
@@ -0,0 +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,+FAA+F;AAC/F,eAAO,MAAM,yBAAyB,qCAAqC,CAAC;AAE5E;;;;;;GAMG;AACH,MAAM,MAAM,IAAI,GAAG,MAAM,GAAG,YAAY,GAAG,UAAU,GAAG,MAAM,CAAC;AAE/D,MAAM,WAAW,oBAAoB;IACnC,0FAA0F;IAC1F,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iGAAiG;IACjG,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC;IACxC,gGAAgG;IAChG,WAAW,CAAC,EAAE,IAAI,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC;IACnC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB;;;;;;;;;OASG;IACH,QAAQ,CAAC,WAAW,EAAE,IAAI,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,WAAW;IAC1B,cAAc,IAAI,iBAAiB,CAAC;IACpC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAED;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IAClC,aAAa,CAAC,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;CACrE;AAED,oGAAoG;AACpG,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,GAAG,mBAAmB,GAAG,SAAS,CAMzF"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * The contract other extensions use to share a camera with this one.
3
+ *
4
+ * Published as its own entry point so a consumer states what it expects instead of re-declaring it.
5
+ * A hand-written copy of an interface compiles perfectly against nothing: when the shape here
6
+ * changes, the copy keeps type-checking in its own repository and fails at runtime in a browser,
7
+ * which is the worst order to find out. Importing these declarations moves that failure to the
8
+ * consumer's build.
9
+ *
10
+ * This module holds no logic and pulls in none of the extension, so importing it costs a consumer
11
+ * nothing at runtime beyond the three constants below.
12
+ */
13
+ /** The extension ID, as it appears in block opcodes and in a project's extension list. */
14
+ export const cameraSourceExtensionId = 'kubohiroyacamerasource';
15
+ /**
16
+ * Where the extension instance puts itself on the VM runtime.
17
+ *
18
+ * Present as soon as the extension is registered. Absent means Camera Source is not loaded, which a
19
+ * consumer has to handle whatever else it does.
20
+ */
21
+ export const cameraSourceRuntimeKey = 'ext_kubohiroyacamerasource';
22
+ /** Where the versioned capability sits, when the build publishing it has that path enabled. */
23
+ export const cameraSourceCapabilityKey = 'kubohiroyaCameraSourceCapability';
24
+ /** Narrows a runtime value to the Camera Source surface, so a missing extension reads as absent. */
25
+ export function readCameraSourceRuntime(runtime) {
26
+ if (typeof runtime !== 'object' || runtime === null)
27
+ return undefined;
28
+ const candidate = runtime[cameraSourceRuntimeKey];
29
+ if (typeof candidate !== 'object' || candidate === null)
30
+ return undefined;
31
+ const { acquireCamera } = candidate;
32
+ return typeof acquireCamera === 'function' ? candidate : undefined;
33
+ }
34
+ //# sourceMappingURL=runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,0FAA0F;AAC1F,MAAM,CAAC,MAAM,uBAAuB,GAAG,wBAAwB,CAAC;AAEhE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,4BAA4B,CAAC;AAEnE,+FAA+F;AAC/F,MAAM,CAAC,MAAM,yBAAyB,GAAG,kCAAkC,CAAC;AAyD5E,oGAAoG;AACpG,MAAM,UAAU,uBAAuB,CAAC,OAAgB;IACtD,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,SAAS,CAAC;IACtE,MAAM,SAAS,GAAI,OAAmC,CAAC,sBAAsB,CAAC,CAAC;IAC/E,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,SAAS,KAAK,IAAI;QAAE,OAAO,SAAS,CAAC;IAC1E,MAAM,EAAC,aAAa,EAAC,GAAG,SAAsC,CAAC;IAC/D,OAAO,OAAO,aAAa,KAAK,UAAU,CAAC,CAAC,CAAE,SAAiC,CAAC,CAAC,CAAC,SAAS,CAAC;AAC9F,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubohiroya/turbowarp-camera-source",
3
- "version": "0.5.0",
3
+ "version": "0.7.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",
@@ -15,10 +15,15 @@
15
15
  },
16
16
  "exports": {
17
17
  "./camera-source.js": "./dist/camera-source.js",
18
+ "./runtime": {
19
+ "types": "./dist/runtime.d.ts",
20
+ "import": "./dist/runtime.js"
21
+ },
18
22
  "./package.json": "./package.json"
19
23
  },
20
24
  "files": [
21
25
  "dist/",
26
+ "schemas/",
22
27
  "README.md",
23
28
  "README.ja.md",
24
29
  "LICENSE"
@@ -36,12 +41,12 @@
36
41
  "scripts": {
37
42
  "dev": "vite build --watch",
38
43
  "typecheck": "tsc --noEmit",
39
- "build": "vite build",
44
+ "build": "vite build && tsc -p tsconfig.lib.json",
40
45
  "lint": "eslint src tests vite.config.ts",
41
46
  "format": "eslint src tests vite.config.ts --fix",
42
47
  "test": "vitest run",
43
48
  "docs": "node scripts/generate-readme.ts",
44
- "docs:check": "pnpm run docs && git diff --exit-code -- README.md",
49
+ "docs:check": "pnpm run docs && git diff --exit-code -- README.md README.ja.md",
45
50
  "docs:pages:check": "node scripts/check-pages.ts",
46
51
  "repo:check": "node scripts/check-repo.ts",
47
52
  "pack:check": "npm pack --dry-run --ignore-scripts",
@@ -54,6 +59,7 @@
54
59
  "@eslint/js": "^9.39.5",
55
60
  "@kubohiroya/vite-plugin-turbowarp-extension": "0.4.0",
56
61
  "@types/node": "^24.13.3",
62
+ "ajv": "^8.20.0",
57
63
  "eslint": "^9.39.5",
58
64
  "typescript": "^5.9.3",
59
65
  "typescript-eslint": "^8.66.0",
@@ -0,0 +1,346 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://kubohiroya.github.io/turbowarp-camera-source/schema/camera-intrinsics-v1.json",
4
+ "title": "Camera intrinsic calibration profile v1",
5
+ "description": "How one camera projects the world onto its own captured image. Carries no world pose: where a camera stands is solved separately against a shared reference, and mixing the two lets a stale extrinsic be read as a current placement.",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": [
9
+ "schema",
10
+ "version",
11
+ "profileId",
12
+ "cameraId",
13
+ "calibratedAt",
14
+ "producer",
15
+ "cameraModel",
16
+ "image",
17
+ "intrinsics",
18
+ "distortion"
19
+ ],
20
+ "properties": {
21
+ "schema": {
22
+ "const": "twcs/camera-intrinsics"
23
+ },
24
+ "version": {
25
+ "const": 1
26
+ },
27
+ "profileId": {
28
+ "$ref": "#/$defs/identifier",
29
+ "description": "Identifies this calibration run. A new solve produces a new id."
30
+ },
31
+ "cameraId": {
32
+ "$ref": "#/$defs/identifier",
33
+ "description": "Operator-assigned camera name such as stage-left. Stable across calibration runs."
34
+ },
35
+ "calibratedAt": {
36
+ "type": "string",
37
+ "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d{1,6})?Z$",
38
+ "description": "When the calibration was solved, as an RFC 3339 timestamp in UTC."
39
+ },
40
+ "producer": {
41
+ "type": "string",
42
+ "minLength": 1,
43
+ "maxLength": 256,
44
+ "description": "Free text naming whatever produced the profile. Diagnostics only; the contract does not care which extension, tool or person it was."
45
+ },
46
+ "cameraModel": {
47
+ "const": "pinhole"
48
+ },
49
+ "image": {
50
+ "type": "object",
51
+ "additionalProperties": false,
52
+ "required": [
53
+ "width",
54
+ "height",
55
+ "undistorted"
56
+ ],
57
+ "description": "The image the calibration was solved against. Always the camera's own capture; preview mirroring is a display choice and never changes the calibration.",
58
+ "properties": {
59
+ "width": {
60
+ "type": "integer",
61
+ "minimum": 1,
62
+ "maximum": 16384
63
+ },
64
+ "height": {
65
+ "type": "integer",
66
+ "minimum": 1,
67
+ "maximum": 16384
68
+ },
69
+ "undistorted": {
70
+ "type": "boolean",
71
+ "description": "False for the base contract: the profile describes the raw frame and the consumer applies the distortion model. True states that the images are already corrected, which then forbids leftover coefficients."
72
+ }
73
+ }
74
+ },
75
+ "intrinsics": {
76
+ "type": "object",
77
+ "additionalProperties": false,
78
+ "required": [
79
+ "fx",
80
+ "fy",
81
+ "cx",
82
+ "cy",
83
+ "skew"
84
+ ],
85
+ "description": "Pinhole parameters in pixels of the calibration image, with x to the right and y downward from the top-left corner. Named rather than packed into an array because nine numbers cannot say whether they are row-major or column-major. The equivalent row-major 3x3 matrix is [fx, skew, cx, 0, fy, cy, 0, 0, 1].",
86
+ "properties": {
87
+ "fx": {
88
+ "type": "number",
89
+ "exclusiveMinimum": 0,
90
+ "maximum": 10000000
91
+ },
92
+ "fy": {
93
+ "type": "number",
94
+ "exclusiveMinimum": 0,
95
+ "maximum": 10000000
96
+ },
97
+ "cx": {
98
+ "type": "number",
99
+ "minimum": -10000000,
100
+ "maximum": 10000000
101
+ },
102
+ "cy": {
103
+ "type": "number",
104
+ "minimum": -10000000,
105
+ "maximum": 10000000
106
+ },
107
+ "skew": {
108
+ "type": "number",
109
+ "minimum": -10000000,
110
+ "maximum": 10000000,
111
+ "description": "Axis skew. Zero for every square-pixel sensor; kept explicit so it is never assumed."
112
+ }
113
+ }
114
+ },
115
+ "distortion": {
116
+ "type": "object",
117
+ "additionalProperties": false,
118
+ "required": [
119
+ "model",
120
+ "coefficients"
121
+ ],
122
+ "properties": {
123
+ "model": {
124
+ "enum": [
125
+ "none",
126
+ "brown-conrady",
127
+ "kannala-brandt"
128
+ ]
129
+ },
130
+ "coefficients": {
131
+ "type": "array",
132
+ "items": {
133
+ "type": "number",
134
+ "minimum": -10000,
135
+ "maximum": 10000
136
+ },
137
+ "description": "Brown-Conrady carries the OpenCV coefficients in their usual order: k1, k2, p1, p2, optionally k3, and k4 to k6 for the rational model. Kannala-Brandt carries the four fisheye coefficients."
138
+ }
139
+ },
140
+ "allOf": [
141
+ {
142
+ "if": {
143
+ "type": "object",
144
+ "required": [
145
+ "model"
146
+ ],
147
+ "properties": {
148
+ "model": {
149
+ "const": "none"
150
+ }
151
+ }
152
+ },
153
+ "then": {
154
+ "type": "object",
155
+ "properties": {
156
+ "coefficients": {
157
+ "type": "array",
158
+ "maxItems": 0
159
+ }
160
+ }
161
+ }
162
+ },
163
+ {
164
+ "if": {
165
+ "type": "object",
166
+ "required": [
167
+ "model"
168
+ ],
169
+ "properties": {
170
+ "model": {
171
+ "const": "brown-conrady"
172
+ }
173
+ }
174
+ },
175
+ "then": {
176
+ "type": "object",
177
+ "properties": {
178
+ "coefficients": {
179
+ "type": "array",
180
+ "anyOf": [
181
+ {
182
+ "minItems": 4,
183
+ "maxItems": 4
184
+ },
185
+ {
186
+ "minItems": 5,
187
+ "maxItems": 5
188
+ },
189
+ {
190
+ "minItems": 8,
191
+ "maxItems": 8
192
+ }
193
+ ]
194
+ }
195
+ }
196
+ }
197
+ },
198
+ {
199
+ "if": {
200
+ "type": "object",
201
+ "required": [
202
+ "model"
203
+ ],
204
+ "properties": {
205
+ "model": {
206
+ "const": "kannala-brandt"
207
+ }
208
+ }
209
+ },
210
+ "then": {
211
+ "type": "object",
212
+ "properties": {
213
+ "coefficients": {
214
+ "type": "array",
215
+ "minItems": 4,
216
+ "maxItems": 4
217
+ }
218
+ }
219
+ }
220
+ }
221
+ ]
222
+ },
223
+ "capture": {
224
+ "type": "object",
225
+ "additionalProperties": false,
226
+ "description": "The capture configuration the calibration was solved under. Optional as a whole, and optional member by member, but the difference matters: an absent block means nothing was recorded and compatibility cannot be decided, while an absent member inside a present block means the device reported no such control at calibration time. frameRate and facingMode are recorded for the operator and do not decide compatibility, because neither changes how the lens projects.",
227
+ "properties": {
228
+ "frameRate": {
229
+ "type": "number",
230
+ "exclusiveMinimum": 0,
231
+ "maximum": 1000
232
+ },
233
+ "facingMode": {
234
+ "type": "string",
235
+ "minLength": 1,
236
+ "maxLength": 256
237
+ },
238
+ "resizeMode": {
239
+ "enum": [
240
+ "none",
241
+ "crop-and-scale"
242
+ ],
243
+ "description": "Cropping changes the effective intrinsics at the same resolution."
244
+ },
245
+ "zoom": {
246
+ "type": "number",
247
+ "exclusiveMinimum": 0,
248
+ "maximum": 1000
249
+ },
250
+ "focusMode": {
251
+ "enum": [
252
+ "none",
253
+ "manual",
254
+ "single-shot",
255
+ "continuous"
256
+ ]
257
+ },
258
+ "focusDistance": {
259
+ "type": "number",
260
+ "minimum": 0,
261
+ "maximum": 10000
262
+ }
263
+ }
264
+ },
265
+ "quality": {
266
+ "type": "object",
267
+ "additionalProperties": false,
268
+ "required": [
269
+ "sampleCount",
270
+ "reprojectionErrorPx"
271
+ ],
272
+ "description": "Optional. Absent means the producer did not report quality, which is not the same as a measured zero.",
273
+ "properties": {
274
+ "sampleCount": {
275
+ "type": "integer",
276
+ "minimum": 1,
277
+ "maximum": 10000
278
+ },
279
+ "reprojectionErrorPx": {
280
+ "type": "number",
281
+ "minimum": 0,
282
+ "maximum": 10000
283
+ }
284
+ }
285
+ },
286
+ "device": {
287
+ "type": "object",
288
+ "additionalProperties": false,
289
+ "description": "Hints for recognizing the physical camera again. deviceId is a hint and not an identity: browsers scope it per origin and per profile, so it changes without the camera changing.",
290
+ "properties": {
291
+ "label": {
292
+ "type": "string",
293
+ "minLength": 1,
294
+ "maxLength": 256
295
+ },
296
+ "deviceId": {
297
+ "type": "string",
298
+ "minLength": 1,
299
+ "maxLength": 256
300
+ }
301
+ }
302
+ }
303
+ },
304
+ "allOf": [
305
+ {
306
+ "if": {
307
+ "type": "object",
308
+ "required": [
309
+ "image"
310
+ ],
311
+ "properties": {
312
+ "image": {
313
+ "type": "object",
314
+ "required": [
315
+ "undistorted"
316
+ ],
317
+ "properties": {
318
+ "undistorted": {
319
+ "const": true
320
+ }
321
+ }
322
+ }
323
+ }
324
+ },
325
+ "then": {
326
+ "type": "object",
327
+ "properties": {
328
+ "distortion": {
329
+ "type": "object",
330
+ "properties": {
331
+ "model": {
332
+ "const": "none"
333
+ }
334
+ }
335
+ }
336
+ }
337
+ }
338
+ }
339
+ ],
340
+ "$defs": {
341
+ "identifier": {
342
+ "type": "string",
343
+ "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,63}$"
344
+ }
345
+ }
346
+ }