@kubohiroya/turbowarp-camera-source 0.15.0 → 0.17.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.
@@ -12,6 +12,11 @@
12
12
  }
13
13
  ]
14
14
  },
15
+ {
16
+ "opcode": "cameraButtonAvailable",
17
+ "blockType": "BOOLEAN",
18
+ "arguments": []
19
+ },
15
20
  {
16
21
  "opcode": "cameraConditionsGeneration",
17
22
  "blockType": "REPORTER",
@@ -217,6 +222,16 @@
217
222
  }
218
223
  ]
219
224
  },
225
+ {
226
+ "opcode": "hideCameraButton",
227
+ "blockType": "COMMAND",
228
+ "arguments": [
229
+ {
230
+ "id": "CAMERA_ID",
231
+ "type": "STRING"
232
+ }
233
+ ]
234
+ },
220
235
  {
221
236
  "opcode": "hideCameraPreview",
222
237
  "blockType": "COMMAND",
@@ -335,6 +350,16 @@
335
350
  }
336
351
  ]
337
352
  },
353
+ {
354
+ "opcode": "startSharedCameraFromCameraButton",
355
+ "blockType": "COMMAND",
356
+ "arguments": [
357
+ {
358
+ "id": "CAMERA_ID",
359
+ "type": "STRING"
360
+ }
361
+ ]
362
+ },
338
363
  {
339
364
  "opcode": "stopSharedCamera",
340
365
  "blockType": "COMMAND",
package/dist/profile.d.ts CHANGED
@@ -10,7 +10,7 @@
10
10
  *
11
11
  * Nothing here touches a camera, a document, or the VM.
12
12
  */
13
- export { CAMERA_INFO_EXTENSION_KEY, readCameraInfoYaml, serializeCameraInfoYaml, type CameraInfoReadResult } from './calibration/camera-info.js';
13
+ export { CAMERA_INFO_EXTENSION_KEY, readCameraInfoYaml, readCameraInfoDocument, serializeCameraInfoYaml, type CameraInfoReadResult } from './calibration/camera-info.js';
14
14
  export { readProfileText, type ProfileTextResult } from './calibration/profile-text.js';
15
15
  export { CAMERA_INTRINSIC_PROFILE_SCHEMA, CAMERA_INTRINSIC_PROFILE_VERSION, readCameraProfileDocument, serializeCameraIntrinsicProfile } from './calibration/profile.js';
16
16
  export { evaluateProfileCompatibility } from './calibration/compatibility.js';
@@ -1 +1 @@
1
- {"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../src/profile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EACL,yBAAyB,EACzB,kBAAkB,EAClB,uBAAuB,EACvB,KAAK,oBAAoB,EAC1B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,eAAe,EACf,KAAK,iBAAiB,EACvB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,+BAA+B,EAC/B,gCAAgC,EAChC,yBAAyB,EACzB,+BAA+B,EAChC,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAC,4BAA4B,EAAC,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EAAC,oBAAoB,EAAC,MAAM,6BAA6B,CAAC;AACjE,YAAY,EACV,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,gCAAgC,CAAC;AACxC,YAAY,EAAC,gBAAgB,EAAC,MAAM,6BAA6B,CAAC;AAClE,YAAY,EACV,kBAAkB,EAClB,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,wBAAwB,EACxB,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACd,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../src/profile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EACL,yBAAyB,EACzB,kBAAkB,EAClB,sBAAsB,EACtB,uBAAuB,EACvB,KAAK,oBAAoB,EAC1B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,eAAe,EACf,KAAK,iBAAiB,EACvB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,+BAA+B,EAC/B,gCAAgC,EAChC,yBAAyB,EACzB,+BAA+B,EAChC,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAC,4BAA4B,EAAC,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EAAC,oBAAoB,EAAC,MAAM,6BAA6B,CAAC;AACjE,YAAY,EACV,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,gCAAgC,CAAC;AACxC,YAAY,EAAC,gBAAgB,EAAC,MAAM,6BAA6B,CAAC;AAClE,YAAY,EACV,kBAAkB,EAClB,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,wBAAwB,EACxB,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACd,MAAM,wBAAwB,CAAC"}
package/dist/profile.js CHANGED
@@ -10,7 +10,7 @@
10
10
  *
11
11
  * Nothing here touches a camera, a document, or the VM.
12
12
  */
13
- export { CAMERA_INFO_EXTENSION_KEY, readCameraInfoYaml, serializeCameraInfoYaml } from './calibration/camera-info.js';
13
+ export { CAMERA_INFO_EXTENSION_KEY, readCameraInfoYaml, readCameraInfoDocument, serializeCameraInfoYaml } from './calibration/camera-info.js';
14
14
  export { readProfileText } from './calibration/profile-text.js';
15
15
  export { CAMERA_INTRINSIC_PROFILE_SCHEMA, CAMERA_INTRINSIC_PROFILE_VERSION, readCameraProfileDocument, serializeCameraIntrinsicProfile } from './calibration/profile.js';
16
16
  export { evaluateProfileCompatibility } from './calibration/compatibility.js';
@@ -1 +1 @@
1
- {"version":3,"file":"profile.js","sourceRoot":"","sources":["../src/profile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EACL,yBAAyB,EACzB,kBAAkB,EAClB,uBAAuB,EAExB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,eAAe,EAEhB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,+BAA+B,EAC/B,gCAAgC,EAChC,yBAAyB,EACzB,+BAA+B,EAChC,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAC,4BAA4B,EAAC,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EAAC,oBAAoB,EAAC,MAAM,6BAA6B,CAAC"}
1
+ {"version":3,"file":"profile.js","sourceRoot":"","sources":["../src/profile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EACL,yBAAyB,EACzB,kBAAkB,EAClB,sBAAsB,EACtB,uBAAuB,EAExB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,eAAe,EAEhB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,+BAA+B,EAC/B,gCAAgC,EAChC,yBAAyB,EACzB,+BAA+B,EAChC,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAC,4BAA4B,EAAC,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EAAC,oBAAoB,EAAC,MAAM,6BAA6B,CAAC"}
@@ -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
+ }
@@ -0,0 +1,57 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://kubohiroya.github.io/turbowarp-camera-source/schema/editor-legacy-calibration.json",
4
+ "title": "Existing Camera Source legacy input shape",
5
+ "type": "object",
6
+ "required": [
7
+ "schema",
8
+ "version",
9
+ "calibrationId",
10
+ "cameraId",
11
+ "imageWidth",
12
+ "imageHeight",
13
+ "intrinsicMatrix",
14
+ "distortionCoefficients",
15
+ "calibratedAt"
16
+ ],
17
+ "properties": {
18
+ "schema": {
19
+ "const": "twrmc/camera-calibration"
20
+ },
21
+ "version": {
22
+ "const": 1
23
+ },
24
+ "calibrationId": {
25
+ "type": "string"
26
+ },
27
+ "cameraId": {
28
+ "type": "string"
29
+ },
30
+ "imageWidth": {
31
+ "type": "number"
32
+ },
33
+ "imageHeight": {
34
+ "type": "number"
35
+ },
36
+ "intrinsicMatrix": {
37
+ "type": "array",
38
+ "items": {
39
+ "type": "number"
40
+ },
41
+ "minItems": 9,
42
+ "maxItems": 9
43
+ },
44
+ "distortionCoefficients": {
45
+ "type": "array",
46
+ "items": {
47
+ "type": "number"
48
+ }
49
+ },
50
+ "calibratedAt": {
51
+ "type": "string"
52
+ },
53
+ "worldFromCameraMatrix": true,
54
+ "worldUnit": true
55
+ },
56
+ "additionalProperties": false
57
+ }
@@ -0,0 +1,29 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://kubohiroya.github.io/turbowarp-camera-source/schema/editor-ros-camera-info.json",
4
+ "title": "Raw ROS camera_info shape (owner validates matrices and metadata)",
5
+ "type": "object",
6
+ "required": [
7
+ "image_width",
8
+ "image_height",
9
+ "camera_name",
10
+ "camera_matrix",
11
+ "distortion_coefficients",
12
+ "turbowarp_camera_source"
13
+ ],
14
+ "properties": {
15
+ "image_width": true,
16
+ "image_height": true,
17
+ "camera_name": true,
18
+ "camera_matrix": true,
19
+ "distortion_model": true,
20
+ "distortion_coefficients": true,
21
+ "rectification_matrix": true,
22
+ "projection_matrix": true,
23
+ "binning_x": true,
24
+ "binning_y": true,
25
+ "roi": true,
26
+ "turbowarp_camera_source": true
27
+ },
28
+ "additionalProperties": false
29
+ }
@@ -0,0 +1,33 @@
1
+ import type { CameraIntrinsicProfileV1, ProfileError } from './types.js';
2
+ /** The top-level key holding the members ROS has no place for. */
3
+ export declare const CAMERA_INFO_EXTENSION_KEY = "turbowarp_camera_source";
4
+ export type CameraInfoReadResult = {
5
+ readonly ok: true;
6
+ readonly document: Record<string, unknown>;
7
+ } | {
8
+ readonly ok: false;
9
+ readonly error: ProfileError;
10
+ };
11
+ /**
12
+ * Renders a profile as a ROS `camera_info` YAML document.
13
+ *
14
+ * The layout follows what `camera_calibration_parsers` writes, key for key and in the same order, so
15
+ * the file reads like one ROS produced. The projection matrix is the calibration matrix with a zero
16
+ * fourth column, which is what a monocular camera with no rectification has; binning and region of
17
+ * interest are left out, as ROS treats them as optional.
18
+ *
19
+ * Strings in the extra mapping are always double-quoted. A timestamp left plain is read as a date
20
+ * by YAML 1.1 readers such as PyYAML, and an id made only of digits as a number.
21
+ */
22
+ export declare function serializeCameraInfoYaml(profile: CameraIntrinsicProfileV1): string;
23
+ /**
24
+ * Turns a ROS `camera_info` YAML document into a profile document, ready to be validated.
25
+ *
26
+ * Only the shape ROS defines is checked here -- matrix sizes, the fixed entries of the calibration
27
+ * matrix, a rectification that does nothing, a distortion model ROS names. Everything the profile
28
+ * contract says about the values themselves is left to the profile validator, so there is one
29
+ * place that decides whether a calibration is acceptable.
30
+ */
31
+ export declare function readCameraInfoYaml(text: string): CameraInfoReadResult;
32
+ /** Validate a raw ROS mapping without serializing or replacing the editable data. */
33
+ export declare function readCameraInfoDocument(parsed: unknown): CameraInfoReadResult;