@kubohiroya/turbowarp-camera-source 0.8.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/camera-source.js +4 -21
- 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);
|
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": {
|
|
@@ -1332,7 +1316,6 @@
|
|
|
1332
1316
|
this.generations = /* @__PURE__ */ new Map();
|
|
1333
1317
|
this.lastConditions = /* @__PURE__ */ new Map();
|
|
1334
1318
|
this.assessments = /* @__PURE__ */ new Map();
|
|
1335
|
-
this.calibrationEnabled = featureFlags.calibrationProfilesV1;
|
|
1336
1319
|
this.devices = [];
|
|
1337
1320
|
this.dispose = () => {
|
|
1338
1321
|
this.stopAllCameras();
|
|
@@ -1347,7 +1330,7 @@
|
|
|
1347
1330
|
this.profileError = void 0;
|
|
1348
1331
|
};
|
|
1349
1332
|
Scratch.vm.runtime[cameraSourceRuntimeKey] = this;
|
|
1350
|
-
this.capability =
|
|
1333
|
+
this.capability = createRuntimeCapability({
|
|
1351
1334
|
registerProfile: (document) => this.profiles.register(document),
|
|
1352
1335
|
forgetProfile: (cameraId) => this.profiles.forget(cameraId),
|
|
1353
1336
|
profileFor: (cameraId) => this.profiles.get(cameraId),
|
|
@@ -1358,8 +1341,8 @@
|
|
|
1358
1341
|
intrinsicsFor: (cameraId) => this.intrinsicsOf(cameraId),
|
|
1359
1342
|
conditionsFor: (cameraId) => this.conditionsOf(cameraId),
|
|
1360
1343
|
conditionsGeneration: (cameraId) => this.generationOf(cameraId)
|
|
1361
|
-
})
|
|
1362
|
-
|
|
1344
|
+
});
|
|
1345
|
+
Scratch.vm.runtime[cameraSourceCapabilityKey] = this.capability;
|
|
1363
1346
|
Scratch.vm.runtime.on?.("PROJECT_STOP_ALL", this.handleProjectBoundary);
|
|
1364
1347
|
Scratch.vm.runtime.on?.("PROJECT_LOADED", this.handleProjectBoundary);
|
|
1365
1348
|
Scratch.vm.runtime.on?.("RUNTIME_DISPOSED", this.dispose);
|
|
@@ -1368,7 +1351,7 @@
|
|
|
1368
1351
|
return {
|
|
1369
1352
|
id: extensionConfig.id,
|
|
1370
1353
|
name: Scratch.translate(block_definitions_default.extensionName),
|
|
1371
|
-
blocks: blockDefinitions.
|
|
1354
|
+
blocks: blockDefinitions.map((block) => this.toScratchBlock(block)),
|
|
1372
1355
|
menus: Object.fromEntries(Object.entries(menuDefinitions).map(([id, menu]) => [id, {
|
|
1373
1356
|
acceptReporters: menu.acceptReporters,
|
|
1374
1357
|
items: [...menu.items]
|
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",
|