@kubohiroya/turbowarp-camera-calibration 0.14.0 → 0.15.1

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.
Files changed (58) hide show
  1. package/README.ja.md +19 -6
  2. package/README.md +19 -6
  3. package/THIRD_PARTY_NOTICES.md +21 -5
  4. package/dist/camera-calibration.js +12447 -2006
  5. package/docs/architecture.ja.md +2 -2
  6. package/docs/architecture.md +2 -2
  7. package/docs/editor-schema-ci-fix-20261018.ja.md +38 -0
  8. package/docs/editor-schema-ci-fix-20261018.json +120 -0
  9. package/docs/editor-schema-profile-compat.json +30 -0
  10. package/docs/editor-schema-publication.ja.md +17 -0
  11. package/docs/editor-schema-publication.json +133 -0
  12. package/docs/editor-schema-verification.json +110 -0
  13. package/docs/editor-schema.ja.md +39 -0
  14. package/docs/index.html +48 -1
  15. package/docs/schemas/block-editor-fixed-inputs.schema.json +68 -0
  16. package/docs/source-editor.ja.md +13 -0
  17. package/docs/stage-2-publication.ja.md +37 -0
  18. package/docs/stage-2-publication.json +91 -0
  19. package/lib/board/pattern.d.ts +7 -4
  20. package/lib/board/pattern.js +7 -4
  21. package/lib/calibration/distortion.d.ts +7 -0
  22. package/lib/calibration/distortion.js +8 -0
  23. package/lib/calibration/types.d.ts +12 -9
  24. package/lib/calibration/types.js +1 -8
  25. package/lib/runtime-capability.d.ts +5 -1
  26. package/lib-editor/schemas/camera-intrinsics-v1.schema.json +158 -0
  27. package/lib-editor/schemas/editor-legacy-input.json +60 -0
  28. package/lib-editor/src/calibration/distortion.d.ts +7 -0
  29. package/lib-editor/src/calibration/distortion.js +8 -0
  30. package/lib-editor/src/calibration/profile.d.ts +104 -0
  31. package/lib-editor/src/calibration/profile.js +392 -0
  32. package/lib-editor/src/editor-schema.d.ts +72 -0
  33. package/lib-editor/src/editor-schema.js +123 -0
  34. package/package.json +27 -11
  35. package/schemas/block-editor-fixed-inputs.schema.json +68 -0
  36. package/schemas/editor-legacy-input.json +60 -0
  37. package/src/block-definitions.json +1 -1
  38. package/src/board/pattern.ts +7 -4
  39. package/src/calibration/camera-source.ts +95 -9
  40. package/src/calibration/controller.ts +396 -78
  41. package/src/calibration/distortion.ts +21 -0
  42. package/src/calibration/measures.ts +94 -0
  43. package/src/calibration/opencv-backend.ts +97 -19
  44. package/src/calibration/opencv-symbols.ts +0 -1
  45. package/src/calibration/pose.ts +133 -38
  46. package/src/calibration/profile.ts +2 -2
  47. package/src/calibration/types.ts +12 -22
  48. package/src/calibration/worker-backend.ts +121 -13
  49. package/src/editor-schema.ts +148 -0
  50. package/src/extension.ts +28 -10
  51. package/src/fixed-input-editors.ts +120 -0
  52. package/src/fixed-input-schema.ts +13 -0
  53. package/src/runtime-capability.ts +5 -1
  54. package/src/source-editors.ts +30 -0
  55. package/templates/README.ja.md +4 -0
  56. package/templates/README.md +4 -0
  57. package/schemas/extension-manifest.schema.json +0 -49
  58. package/src/extension-manifest.ts +0 -149
package/README.ja.md CHANGED
@@ -74,6 +74,7 @@ whitelistでbuildし直し、10.9 MBから3.85 MBにしています。詳しく
74
74
  | 板をサンプルごとに約20°〜45°、異なる向きへ傾ける | 正対した画像ばかりでは焦点距離と距離を分離できません。横へずらすだけでは足りず、傾けていない組は`sample-poses-degenerate`で拒否します |
75
75
  | 距離を変え、画面の隅を含む別々の位置に板を写す | 歪みは画像中心から離れるほど大きく現れます。マーカーがコーナーに名前を与えるので、画面からはみ出した板も写っている分のコーナーを使えます |
76
76
  | ピントを合わせ、少し止めて持つ | ぶれた画像は`sample-low-quality`で拒否するか、自動経路では`hold-steadier`と案内します |
77
+ | オートフォーカスを切り、カメラ自身の設定でピントを固定する | 連続オートフォーカスは板の動きに合わせて焦点距離を変えます。Camera Sourceはカメラの設定を読むだけで変更しないため、プロジェクトからは固定できません。ピントが動くと、その視点で`capture-condition-mismatch`になりセッションが終わります |
77
78
  | セッション中に解像度・カメラdevice・左右反転・リサイズ・focus・zoomを変えない | セッションは開始時の条件に固定されます。変われば、カメラに合わないプロファイルを作る代わりに`capture-condition-mismatch`で終わります |
78
79
  | 印刷板か1:1表示の画面を使い、プロジェクタは避ける | 台形補正、斜めからの投影、プロジェクタ自身のレンズ歪みが板を変形させ、しかも再投影誤差には現れません |
79
80
 
@@ -138,7 +139,7 @@ Node.jsやbuild環境を用意する必要はありません。専用buildのOpe
138
139
  検証済みのversionをexact pinします。
139
140
 
140
141
  ```bash
141
- pnpm add --save-exact @kubohiroya/turbowarp-camera-calibration@0.14.0
142
+ pnpm add --save-exact @kubohiroya/turbowarp-camera-calibration@0.15.1
142
143
  ```
143
144
 
144
145
  standalone bundle:
@@ -150,7 +151,7 @@ node_modules/@kubohiroya/turbowarp-camera-calibration/dist/camera-calibration.js
150
151
  version固定CDN URL:
151
152
 
152
153
  ```text
153
- https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-camera-calibration@0.14.0/dist/camera-calibration.js
154
+ https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-camera-calibration@0.15.1/dist/camera-calibration.js
154
155
  ```
155
156
 
156
157
  ## クイックスタート
@@ -323,7 +324,7 @@ block referenceは
323
324
  | `camera [CAMERA_ID] calibration reprojection error px` | Reporter | 直近のsolveまたは取り込んだプロファイルのRMS再投影誤差(px) |
324
325
  | `camera [CAMERA_ID] calibration pose spread` | Reporter | 採用サンプルの傾きの広がり。0はすべて同じ向きで、solveできません |
325
326
  | `camera [CAMERA_ID] calibration holdout error px` | Reporter | solveのfitに使っていないサンプルでのRMS再投影誤差(px) |
326
- | `camera [CAMERA_ID] calibration holdout sample count` | Reporter | 検証用に残したサンプル数。0なら何も検証していません |
327
+ | `camera [CAMERA_ID] calibration holdout sample count` | Reporter | 検証用に残したサンプルのうち、実際に検証できた数。0なら何も検証していません |
327
328
  | `camera [CAMERA_ID] calibration error code` | Reporter | 依存・board・カメラ・サンプル・solve・再投影・プロファイル・登録の各エラーの安定コード |
328
329
  | `camera [CAMERA_ID] calibration error` | Reporter | 詳細な診断メッセージ |
329
330
  | `camera [CAMERA_ID] calibration profile JSON` | Reporter | 保存中の内部校正プロファイル。無い場合は空文字列 |
@@ -340,15 +341,23 @@ block referenceは
340
341
  | 手動で、板が見つからない・別の板・ぶれている・既存サンプルと似すぎている | `board-not-found`、`wrong-board`、`sample-low-quality`、`sample-too-similar`で却下し、セッションはreadyのままです |
341
342
  | 同じことが自動撮影中に起きた | エラーにせず、guidance reporterで次にすることを示します |
342
343
  | 採用サンプルが40枚 | 手動では`sample-limit`。自動では最も他と似ている1枚を入れ替えます |
344
+ | 検出したコーナーが板上の一直線に並んでいる | 手動では`sample-low-quality`で却下し、自動ではguidanceで`show-the-board`を示します。そのようなビューからの姿勢計測は`board-pose-unavailable`です |
345
+ | ソルバーがframeまたはサンプル組を処理できなかった | `sample-failed`または`solve-failed`。セッションはサンプルとカメラを保ったままreadyに戻り、やり直せます |
346
+ | 自動撮影の1回の撮影が失敗し、セッションは続いている | エラーを記録して撮影を続けます。3回続けて失敗すると停止し、guidanceを空にします |
347
+ | ソルバーのworkerが応答しなくなった、またはWebAssemblyモジュールがabortした | 120秒で、またはworkerがエラーを報告した・モジュールがabortした時点で呼び出しを失敗させ、次の呼び出しで新しいworkerを起動します |
348
+ | 検証用に残した視点のうち、解いた結果で姿勢を求められたものが2つ未満 | 手動では確かめられなかったとして`reprojection-too-high`。自動撮影は収集を続けます |
349
+ | 自動撮影がsolve中に、手動でサンプル追加・solveした | サンプル追加はそのsolveが終わるまで却下します。solveはその完了を待ち、セッションが終わっていなければ改めて解いて自身の結果を返します |
343
350
  | 傾けていない組でsolve | `sample-poses-degenerate`。セッションは開いたままでサンプルを追加できます |
344
351
  | セッション中に解像度・device・左右反転が変わった | `resolution-mismatch` または `capture-condition-mismatch` |
345
- | 解くまでの間にリサイズ・ズーム・フォーカス・カメラが変わった | `capture-condition-mismatch`。camera-source がこのカメラに合わないと判定するプロファイルになるため、`solved` ではなく `error` で終わる |
346
- | 再投影誤差が上限を超えた | `reprojection-too-high`。プロファイルは保存せず、サンプルを追加できます |
352
+ | セッション中にリサイズ・ズーム・フォーカス・カメラが変わった | 次の視点で、またsolveを確定する前にも`capture-condition-mismatch`。camera-source がこのカメラに合わないと判定するプロファイルになるため、`solved` ではなく `error` で終わる |
353
+ | 再投影誤差が上限を超えた | `reprojection-too-high`。プロファイルは保存せず、サンプルを追加できます。手動のsolveも自動撮影と同じく、検証用に2視点以上残したときはfit側に加えてhold-out誤差を確かめます |
347
354
  | 別のカメラ、または別の撮影サイズのプロファイル | 状態を変更する前に`calibration-not-applicable`で拒否します |
355
+ | プロファイルと異なるサイズのframe、またはCamera Sourceがプロファイルに合わないと判定するカメラで板の姿勢を測る | Camera Sourceの理由を添えて`calibration-not-applicable`。比較できない設定や、補正済み画像のプロファイルも含みます。計測せずにカメラを解放します。設定を記録していないプロファイル、または設定をまったく報告しないCamera Sourceでは、これまでどおり計測します |
348
356
  | 校正の無いカメラ、または板が写っていない状態で姿勢を測る | `not-calibrated` または `board-pose-unavailable` |
349
357
  | solve成功 | ただちにカメラのleaseを解放します |
350
- | project停止・project再読込・runtime破棄 | すべてのセッションを取り消し、すべてのleaseを解放します |
358
+ | project停止・project再読込・runtime破棄 | すべてのセッションを取り消し、すべてのleaseを解放します。solveまたはimportしたプロファイルはプロジェクトではなくカメラを表すため、project停止・再読込では保持し、セッションの残っていないカメラは数値ごと`solved`のままです。runtime破棄とcleanupブロックで破棄します |
351
359
  | 無効な入力 | セッション状態を変更する前に拒否します。boardを打ち間違えた再開始も、実行中のセッションを壊しません |
360
+ | `DICT_4X4_50`の50個を超えるマーカーが必要な板(例: 10×9は55個) | 最初のframeではなく開始時に`invalid-board`で拒否します |
352
361
 
353
362
  共有カメラごとにセッション、プロファイル、診断を分けて保持します。あるカメラの
354
363
  cancelが、別のカメラのleaseを解放したり、同じ共有カメラの他の利用者を止めたり
@@ -479,3 +488,7 @@ CIの別ステップで実行します。OpenCV自体のbuildし直しは
479
488
  [`THIRD_PARTY_NOTICES.md`](THIRD_PARTY_NOTICES.md)に記載しています。bundleは
480
489
  この機能拡張のためにbuildしたApache License 2.0のOpenCV.js `4.12.0`を
481
490
  インライン展開しています。
491
+
492
+ 固定入力の編集は拡張構築時の任意editor APIを使います。後からのAPI追加・差替えにはGUI再読込と拡張インスタンス再構築が必要です。Dialogs/FixedInputsは起動時既定OFFです。未変更rawは保持し、reporterは評価しません。機器・sessionの実行条件は実行時検証の責務です。固定fieldのSchema正本は`schemas/block-editor-fixed-inputs.schema.json`、`docs/schemas/`は`scripts/generate-fixed-input-docs.mjs`による生成物です。Schema URIは識別子で、編集時に取得しません。
493
+
494
+ 今回のS3-4候補はCamera Sourceをimmutable Git commit `e23f2e1e3db28c5b7e0290949cf99004b689d90c`へ固定し、manifest・lock・実解決のbytes・間接C3依存を一緒に検証します。旧`e11cc43ec35ff333bbefd50e8dcb461ee939c102`は切戻し基準として保持します。PR作成・merge・npm公開・S3-5は別工程であり、まだ実施していません。
package/README.md CHANGED
@@ -74,6 +74,7 @@ profile that carries a pairing credential is rejected rather than stored.
74
74
  | Tilt the board roughly 20°–45° in different directions across samples | Views that are all fronto-parallel cannot separate focal length from distance. Sliding the board sideways does not help, and a set that was never tilted is refused as `sample-poses-degenerate` |
75
75
  | Vary the distance, and fill different parts of the frame, including the corners | Distortion is strongest away from the image center. The markers name the corners, so a board that runs off the frame still contributes the corners it shows |
76
76
  | Keep the board in focus and hold it still for a moment | A blurred view is refused as `sample-low-quality`, or the automatic path asks to `hold-steadier` |
77
+ | Lock the focus in the camera's own settings, rather than leaving autofocus on | Continuous autofocus moves the focal length as the board moves. Camera Source reads the camera's settings and never changes them, so this cannot be done from a project; a focus that moves ends the session at that view with `capture-condition-mismatch` |
77
78
  | Do not change resolution, camera device, mirroring, resize mode, focus, or zoom during a session | The session is fixed to the conditions it started with; a change ends it with `capture-condition-mismatch` rather than a profile that does not fit the camera |
78
79
  | Prefer a printed board or a 1:1 display; avoid projectors | Keystone correction, oblique projection, and the projector's own lens distort the board in ways the reprojection error does not show |
79
80
 
@@ -142,7 +143,7 @@ and is about 3.9 MB (about 1.5 MB gzip).
142
143
  Install an exact version that you have reviewed:
143
144
 
144
145
  ```bash
145
- pnpm add --save-exact @kubohiroya/turbowarp-camera-calibration@0.14.0
146
+ pnpm add --save-exact @kubohiroya/turbowarp-camera-calibration@0.15.1
146
147
  ```
147
148
 
148
149
  Load the standalone bundle from:
@@ -154,7 +155,7 @@ node_modules/@kubohiroya/turbowarp-camera-calibration/dist/camera-calibration.js
154
155
  A version-pinned CDN URL is:
155
156
 
156
157
  ```text
157
- https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-camera-calibration@0.14.0/dist/camera-calibration.js
158
+ https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-camera-calibration@0.15.1/dist/camera-calibration.js
158
159
  ```
159
160
 
160
161
  ## Quick start
@@ -559,7 +560,7 @@ Returns the RMS reprojection error over the samples the solve was not fitted to.
559
560
 
560
561
  ### `camera [CAMERA_ID] calibration holdout sample count`
561
562
 
562
- Returns how many samples were held back from the solve. Zero means nothing was validated, so the holdout error says nothing.
563
+ Returns how many samples held back from the solve were validated: the ones a pose could be solved for with its answer. Zero means nothing was validated, so the holdout error says nothing.
563
564
 
564
565
  | Property | Value |
565
566
  |---|---|
@@ -620,15 +621,23 @@ Returns the last measured board pose as JSON, or an empty string when none was m
620
621
  | Board not found, another board shown, blurred, or too similar to a kept view (by hand) | The sample is refused with `board-not-found`, `wrong-board`, `sample-low-quality`, or `sample-too-similar`, and the session stays ready |
621
622
  | The same, during automatic capture | No error; the guidance reporter says what to do instead |
622
623
  | 40 samples kept | By hand: `sample-limit`. Automatic: the view most like the others is replaced |
624
+ | A view whose corners lie on one line of the board | Refused as `sample-low-quality` by hand; the automatic path asks to `show-the-board`. A board pose from such a view is `board-pose-unavailable` |
625
+ | The solver fails on a frame or a set | `sample-failed` or `solve-failed`; the session stays ready with its views and its camera, so the step can be tried again |
626
+ | A look by automatic capture fails and the session survives it | Capture keeps watching and the error is recorded; after three failures in a row it stops and clears its guidance |
627
+ | The solver's worker stops answering, or its WebAssembly module aborts | The call fails after 120 s, or at once when the worker reports an error or the module aborts, and the next call starts a new worker |
628
+ | Views are held back but fewer than two of them can be posed with the solved answer | By hand: `reprojection-too-high`, because the answer could not be checked. Automatic capture keeps collecting |
629
+ | Sample or solve by hand while automatic capture is solving | A sample is refused until that solve ends. A solve waits for it and, unless it finished the session, solves as asked and reports its own result |
623
630
  | Solve from a set that was never tilted | `sample-poses-degenerate`; the session stays open for more samples |
624
631
  | Resolution, device, or mirroring changes mid-session | `resolution-mismatch` or `capture-condition-mismatch` |
625
- | Resize mode, zoom, focus, or the camera changes before the solve | `capture-condition-mismatch`; the session ends in `error` rather than `solved`, because Camera Source would judge the profile not to fit this camera |
626
- | Reprojection error exceeds the session limit | `reprojection-too-high`; no profile is stored and more samples can be added |
632
+ | Resize mode, zoom, focus, or the camera changes during the session | `capture-condition-mismatch` at the next view, and again before a solve lands; the session ends in `error` rather than `solved`, because Camera Source would judge the profile not to fit this camera |
633
+ | Reprojection error exceeds the session limit | `reprojection-too-high`; no profile is stored and more samples can be added. A solve by hand checks the hold-out error as well as the fit error, as automatic capture does, once at least two views were held back |
627
634
  | Profile belongs to another camera or another capture size | `calibration-not-applicable`, rejected before any state changes |
635
+ | Board pose measured on a frame of another size than the profile, or on a camera Camera Source does not judge the profile to fit | `calibration-not-applicable` with Camera Source's reasons, including a setting it cannot compare and a profile of already undistorted images; nothing is measured and the camera is released. A profile that recorded no settings, or a Camera Source that reports none, is measured with as before |
628
636
  | Board pose requested without a calibration, or with the board out of view | `not-calibrated` or `board-pose-unavailable` |
629
637
  | Solve succeeds | The camera lease is released immediately |
630
- | Project stop, project reload, runtime disposal | Every session is cancelled and every camera lease is released |
638
+ | Project stop, project reload, runtime disposal | Every session is cancelled and every camera lease is released. A solved or imported profile is kept across a project stop or reload, because it describes the camera rather than the project, and a camera with no session left stays `solved` with its numbers; runtime disposal and the cleanup block forget it |
631
639
  | Invalid input | Rejected before any session state changes, including a restart with a mistyped board |
640
+ | A board needing more than the 50 markers of `DICT_4X4_50` (for example 10 by 9, which needs 55) | `invalid-board`, at the start rather than at the first frame |
632
641
 
633
642
  Each shared camera has its own session, profile, and diagnostics. Cancelling one
634
643
  camera never releases another camera's lease or stops another consumer of the
@@ -763,3 +772,7 @@ described in [`tools/opencv/README.md`](tools/opencv/README.md).
763
772
  Third-party components are listed in
764
773
  [`THIRD_PARTY_NOTICES.md`](THIRD_PARTY_NOTICES.md). The bundle inlines a build of
765
774
  OpenCV.js `4.12.0` made for this extension, distributed under the Apache License 2.0.
775
+
776
+ Fixed input editing uses the optional editor API present at extension construction; late API replacement requires GUI reload and instance reconstruction. Dialogs and FixedInputs are startup flags, both off by default. Unchanged literals stay raw; reporters are never evaluated. Device/session prerequisites remain runtime checks. The canonical fixed field schema is `schemas/block-editor-fixed-inputs.schema.json`; `docs/schemas/` is generated by `scripts/generate-fixed-input-docs.mjs`. The schema URI identifies the contract and is not fetched during editing.
777
+
778
+ This S3-4 candidate pins Camera Source to the immutable Git commit `e23f2e1e3db28c5b7e0290949cf99004b689d90c`. Its manifest, lockfile, installed package bytes and transitive C3 dependency are verified together. The earlier `e11cc43ec35ff333bbefd50e8dcb461ee939c102` remains the rollback baseline. PR creation, merge, npm publication and S3-5 remain separate steps and have not been performed.
@@ -1,7 +1,9 @@
1
1
  # Third-party notices
2
2
 
3
3
  `dist/camera-calibration.js` is a standalone bundle. Everything it needs at run time is inlined,
4
- including the components listed below.
4
+ including the runtime components listed below. The explicit `./editor-schema` entry also
5
+ depends on the first-party artifacts documented here; that entry is not inlined into the
6
+ extension bundle.
5
7
 
6
8
  ## OpenCV.js
7
9
 
@@ -33,16 +35,30 @@ version `4.4.2`, distributed under the Apache License 2.0.
33
35
 
34
36
  The contract this extension talks to is imported from
35
37
  [`@kubohiroya/turbowarp-camera-source`](https://github.com/kubohiroya/turbowarp-camera-source) at the
36
- exact version `0.8.0`, through its `./runtime` sub-entry: the camera lease, the runtime capability,
37
- and the intrinsic profile document. That entry is declarations and a few string constants, and its
38
- built form imports nothing at all, so nothing of Camera Source reaches
39
- `dist/camera-calibration.js` beyond those constants. It is imported rather than copied because a
38
+ exact npm version `0.17.1`
39
+ (selected Git base `e23f2e1e3db28c5b7e0290949cf99004b689d90c`, packaged as a local release overlay), through its `./runtime` sub-entry: the camera lease, the runtime capability,
40
+ and the intrinsic profile document. That runtime entry contains declarations and a few string
41
+ constants; its built form imports nothing, so using this entry adds no camera controller or
42
+ device code to the bundle. The separate pure profile entry is described below. It is imported rather than copied because a
40
43
  copy is checked against nothing: this repository's own hand-written copy named a registry method
41
44
  Camera Source does not have, and every attempt to publish a profile failed for a reason that had
42
45
  nothing to do with what the message said.
43
46
 
44
47
  Camera Source is distributed under the Mozilla Public License 2.0.
45
48
 
49
+ Its pure `./profile` entry supplies calibration parsing and validation used by the runtime
50
+ bundle. Its `./editor-schema` entry supplies the shared profile Schemas used only by this
51
+ package's explicit editor entry and optional Source/Form registration.
52
+
53
+ ## Extension Data Editor
54
+
55
+ The pure Schema engine and diagnostic helpers used by the explicit `./editor-schema` entry
56
+ and optional Source/Form registration
57
+ come from `@kubohiroya/turbowarp-extension-data-editor/schema`, at exact npm version `0.2.1`
58
+ (selected Git base `485f0e550e622235624b5e9176820161aeeba252`, packaged as a working-tree release overlay).
59
+ They do not introduce the RJSF UI into the runtime bundle. Extension Data Editor is distributed
60
+ under the Mozilla Public License 2.0.
61
+
46
62
  ## This extension
47
63
 
48
64
  `@kubohiroya/turbowarp-camera-calibration` itself is distributed under the Mozilla Public License