@depz/camera-sdk 0.0.0-stage → 0.3.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.
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,137 @@
1
- # Temporary Holding Version
1
+ # @depz/camera-sdk
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The DEPZ stereo camera SDK for Node.js (20 or newer): cameras, recordings, the depth pipeline,
4
+ models and engines, calibrations. A Node-API addon over the native SDK's C ABI
5
+ (`contracts/sdk/c_api.md`), with an idiomatic TypeScript API on top.
6
+
7
+ > Not published yet. The package is built and tested from this repository
8
+ > (`packages/depz-camera-sdk-ts/tools/run_tests.sh`); nothing goes to npm.
9
+
10
+ ## Install
11
+
12
+ ```sh
13
+ npm install @depz/camera-sdk
14
+ ```
15
+
16
+ npm also installs the platform package for this machine through `optionalDependencies`:
17
+ `@depz/camera-sdk-linux-x64`, `-linux-arm64`, `-darwin-arm64` or `-win32-x64`. That package holds
18
+ the addon (`depz_node.node`) and the native libraries (`libdepz`, `libdepz_inference`,
19
+ `libdepz_depth`, the engine plugins in `depz-engines/`) side by side. The addon finds the
20
+ libraries in its own folder, so no library path needs to be set. The addon uses Node-API, so one
21
+ build serves every Node version from 20 on.
22
+
23
+ ## Use
24
+
25
+ ```js
26
+ const sdk = require("@depz/camera-sdk"); // or: import sdk from "@depz/camera-sdk"
27
+
28
+ // a recording, replayed frame by frame through the depth stage
29
+ const model = await sdk.buildInference("lightstereo", "s-sceneflow-opt-256x512", { engine: "onnx-cpu" });
30
+ const source = new sdk.MkvSource("recording.mkv", { replayMode: "every_frame" });
31
+ const pipeline = new sdk.Pipeline(source, [new sdk.DepthStage(model)], new sdk.PipelineConfig({ streams: ["depth"] }));
32
+ await pipeline.start();
33
+ for await (const packet of pipeline.frames()) {
34
+ const depth = packet.depth; // ImageView: Float32 metres, 0 = no depth; null: no depth stream
35
+ if (depth !== null) console.log(packet.ptsUs, depth.width, depth.height, depth.pixels()[0]);
36
+ }
37
+ await pipeline.stop();
38
+
39
+ // a camera
40
+ const camera = await sdk.findCamera(); // the first usable one; or findCamera("RRX6L1PSJ4")
41
+ const live = new sdk.Pipeline(new sdk.CameraSource(camera), [new sdk.DepthStage(model)]);
42
+ ```
43
+
44
+ The examples are in `examples/`:
45
+
46
+ - `replay-depth.mjs` (a recording through the depth stage; run by the tests);
47
+ - `list-cameras.mjs` (the attached cameras, their modes and calibration; it needs a camera).
48
+
49
+ The engines a model runs on come in engine packs. Install them with the native SDK's command
50
+ `depz engines install cpu`. `describeEngines()` lists what this host has. A model's files are
51
+ downloaded on first use (`buildInference`) or ahead of it (`downloadModel`).
52
+
53
+ ## The API
54
+
55
+ The names are the reference's (the Python `depz_camera_sdk`), written in TypeScript's conventions:
56
+
57
+ - Classes and types are PascalCase, as there: `Calibration`, `Pipeline`, `MkvSource`, `DepthStage`.
58
+ - Functions, methods, properties and options are lowerCamelCase, with the unit suffix kept:
59
+ `Calibration.fromJson`, `baselineM`, `ptsUs`, `findCamera`, `buildInference`, `controls("inference").set(...)`.
60
+ - The values of the reference's string enums are string literal types: `"every_frame"`,
61
+ `"rectified_left"`, `"continuous"`.
62
+ - Nanoseconds (`*Ns`) are `bigint`, because a host clock does not fit a double; every other number
63
+ is a `number`.
64
+ - A blocking call returns a Promise and runs off the main thread: `open`, `grab`, `start`, `get`,
65
+ `stop`, `buildInference`, `downloadModel`, `findCamera`, `scanCameras`, a recording's `stop` and
66
+ `captureStill`. Progress reports arrive on the main thread, and an `AbortSignal` cancels the call
67
+ (`aborted`).
68
+ - Frames are not copied. An `ImageView`'s `buffer` is the frame's own memory, and it keeps the
69
+ frame alive until it is garbage collected. `pixels()` gives typed rows (`Uint8Array` BGR,
70
+ `Float32Array` depth / disparity / XYZ). `release()` gives a frame or another native object
71
+ back at once, without waiting for the collector.
72
+ - The SDK's log records go to `Settings.log` (`(level, logger, message)`, on the main thread):
73
+ `configure(new Settings({ log, logLevel: LOG_LEVELS.info }))`.
74
+
75
+ ### Errors
76
+
77
+ There is one error type: `DepzError`, with `code` (`ErrorCode`, the frozen values of
78
+ `contracts/errors.json`), `message` (a line for logs) and `details` (a JSON object: the serial,
79
+ the path, the engine, ...). There are no subclasses. `errorCodeName(e.code)` gives the name
80
+ (`"camera_busy"`) and `errorCodeMeaning` gives its meaning.
81
+
82
+ ```js
83
+ try {
84
+ await new sdk.MkvSource("missing.mkv").open();
85
+ } catch (e) {
86
+ if (e instanceof sdk.DepzError && e.code === sdk.ErrorCode.NotFound) console.log(e.details.path);
87
+ }
88
+ ```
89
+
90
+ ## How it is built
91
+
92
+ - `addon/`: the Node-API addon in C++17 over the C headers only, never the C++ wrapper `depz.hpp`.
93
+ Its struct converters, the handles' release functions and the struct layout table are
94
+ **generated** (`addon/records.g.h`).
95
+ - `src/`: the TypeScript layer. `src/generated/` holds every C constant, `ErrorCode` and the record
96
+ types, also generated.
97
+ - `tools/gen_bindings.py` writes the generated files from `contracts/sdk/include/depz/*.h` and
98
+ `contracts/errors.json`. It reads the headers with the C# binding's parser, so every binding
99
+ has one reading of the C ABI. `--check` is part of `make check-generated`.
100
+ - The build tool is node-gyp (with npm). Node-API gives one prebuilt addon per platform, and the
101
+ addon is one file built against the prebuilt libdepz, so the native SDK's CMake is not driven
102
+ from npm.
103
+
104
+ ## Tests
105
+
106
+ ```sh
107
+ packages/depz-camera-sdk-ts/tools/run_tests.sh # or: make test-ts
108
+ ```
109
+
110
+ The script runs these steps:
111
+
112
+ 1. It checks that the generated files are current.
113
+ 2. It fetches Node from nodejs.org (sha256 checked) into a cache folder (`DEPZ_NODE_VERSIONS`,
114
+ default `24 22 20`).
115
+ 3. It builds the native SDK (or takes `DEPZ_LIB_DIR`), then the addon and the TypeScript layer.
116
+ 4. It installs the cpu engine pack, fetches the neural golden cases' models, and runs
117
+ `examples/replay-depth.mjs`.
118
+ 5. It packs the packages with `npm pack` and installs them into an empty project.
119
+ 6. It runs the `node:test` tests on each Node version, with no site, camera or web copy reached.
120
+
121
+ The tests are parity tests over `contracts/`:
122
+
123
+ | Family | Test file | What |
124
+ |---|---|---|
125
+ | layout | `test/abi.test.mjs` | every struct's size and offsets: the C compiler's (`test/generated/abi_probe.g.c`) against the addon's |
126
+ | errors | `test/errors.test.mjs` | `ErrorCode` = `errors.json`, the C ABI's errors both ways, `contracts/sdk/error_cases.json` |
127
+ | calibration | `test/calibration.test.mjs` | `calibration/api_vectors.json`, `sdk_json_vectors.json`, the C-reachable parts of `calibration-storage/test_vectors.json`, `camera_models.json` |
128
+ | model support | `test/model_support.test.mjs` | `model-support/` (engine slugs, support, regions, input sizes, model files, engine caches, the default model) |
129
+ | golden | `test/golden.test.mjs` | `golden/`: the classical and the onnx-cpu cases end to end |
130
+ | recordings | `test/replay.test.mjs` | `recording/vectors.json`: the reader and the replay script; a pipeline's replay; log records |
131
+ | cameras | `test/cameras.test.mjs` | no camera listed; the families' modes and controls (`cameras/`) |
132
+ | pipeline | `test/pipeline.test.mjs` | controls by scope; a recording written and read back |
133
+
134
+ ## Licence
135
+
136
+ The TypeScript layer and the addon's sources are under Apache-2.0. The native libraries in the
137
+ platform packages are under the DEPZ Camera Software License Agreement (their `LICENSE`).
@@ -0,0 +1,168 @@
1
+ import { type NativeHandle, type RawControlWithMembers } from "./native";
2
+ /** One camera model of the catalog (contracts/camera_models.json): what a valid serial names. */
3
+ export interface CameraModel {
4
+ readonly id: string;
5
+ readonly sku: string;
6
+ readonly formerSkus: readonly string[];
7
+ readonly serialPrefix: string;
8
+ readonly cameraFamily: string;
9
+ readonly firmwareImage: string;
10
+ readonly usbPid: string;
11
+ readonly eyeRotationDeg: number;
12
+ readonly isMono: boolean;
13
+ readonly lensClass: string;
14
+ /** The nominal baseline; null: mono, or none in the catalog. */
15
+ readonly baselineM: number | null;
16
+ readonly name: string;
17
+ readonly shortName: string;
18
+ }
19
+ /** The model a valid serial names (the bare serial, "VRX6L1PSJ4"); null for a serial that is not valid. */
20
+ export declare function cameraModelOfSerial(serial: string): CameraModel | null;
21
+ /** The model of a USB product id: 4 hexadecimal digits, any case ("e000"), or the number (0xe000);
22
+ * null when none. */
23
+ export declare function cameraModelOfPid(pid: string | number): CameraModel | null;
24
+ /** The model of a catalog sku, of today or a former one; null when none. */
25
+ export declare function cameraModelOfSku(sku: string): CameraModel | null;
26
+ /** A control's kind: a whole number, a number, a switch, or one of its members. */
27
+ export type ControlType = "int" | "float" | "bool" | "enum";
28
+ /** One member of an enum control. */
29
+ export interface EnumMember {
30
+ readonly value: number | string;
31
+ readonly label: string;
32
+ }
33
+ /** A control: data (the reference's Control). A value is a number, or a word for an enum of words. */
34
+ export interface Control {
35
+ readonly name: string;
36
+ readonly label: string;
37
+ readonly unit: string;
38
+ readonly type: ControlType;
39
+ /** null when not bounded or not stepped. */
40
+ readonly min: number | null;
41
+ readonly max: number | null;
42
+ readonly step: number | null;
43
+ /** null: not known (a camera control that could not be read). */
44
+ readonly value: number | string | null;
45
+ readonly default: number | string | null;
46
+ readonly enumValues: readonly (number | string)[];
47
+ readonly enumMembers: readonly EnumMember[];
48
+ readonly writable: boolean;
49
+ readonly autoCompanion: string;
50
+ readonly updatableByAuto: boolean;
51
+ }
52
+ /** A control record of the C ABI as the reference's Control (has_value / has_default 0: None). Internal. */
53
+ export declare function controlOf(c: RawControlWithMembers): Control;
54
+ /** An eye. */
55
+ export type Eye = "left" | "right";
56
+ /** The C value of an eye; undefined / null: the default (DEPZ_EYE_DEFAULT). Internal. */
57
+ export declare function eyeValue(eye: Eye | null | undefined, what?: string): number;
58
+ export declare function eyeOf(value: number): Eye;
59
+ /** A number as Python's repr of a float writes it ("0.0", "1e-09"): the reference's messages. Internal. */
60
+ export declare function pyFloat(x: number): string;
61
+ /** A region of the rectified frame (the reference's InferenceRoi): fractions, and the width the
62
+ * whole frame has at the model's scale. */
63
+ export declare class InferenceRoi {
64
+ readonly x: number;
65
+ readonly y: number;
66
+ readonly w: number;
67
+ readonly h: number;
68
+ readonly frameWidth: number;
69
+ /** Refuses (invalid_argument) a region outside the frame or a frame width under 32. */
70
+ constructor(x: number, y: number, w: number, h: number, frameWidth: number);
71
+ /** Internal: the C record. */
72
+ toRaw(): {
73
+ x: number;
74
+ y: number;
75
+ w: number;
76
+ h: number;
77
+ frameWidth: number;
78
+ };
79
+ }
80
+ /** What withCanvas makes: the canvas size, the eye size it is for, a region, the right eye's shift, the eye. */
81
+ export interface CanvasOptions {
82
+ canvasWidth: number;
83
+ canvasHeight: number;
84
+ /** One eye as the camera delivers it; omitted: the calibration's image size. */
85
+ eyeWidth?: number;
86
+ eyeHeight?: number;
87
+ roi?: InferenceRoi | null;
88
+ rightShiftPx?: number;
89
+ eye?: Eye;
90
+ }
91
+ /** Where the rectified eye sits in the canvas (the reference's CanvasLayout). */
92
+ export interface CanvasLayout {
93
+ readonly scale: number;
94
+ readonly validW: number;
95
+ readonly validH: number;
96
+ readonly padX: number;
97
+ readonly padY: number;
98
+ readonly eyeW: number;
99
+ readonly eyeH: number;
100
+ readonly frameX: number;
101
+ readonly frameY: number;
102
+ readonly frameW: number;
103
+ readonly frameH: number;
104
+ readonly rightShiftPx: number;
105
+ readonly eye: Eye;
106
+ readonly canvasWidth: number;
107
+ readonly canvasHeight: number;
108
+ readonly isLatlon: boolean;
109
+ readonly isBorderReplicate: boolean;
110
+ }
111
+ /** A BGR8 picture: rows of strideBytes (>= 3 x width). */
112
+ export interface BgrImage {
113
+ readonly data: Uint8Array;
114
+ readonly width: number;
115
+ readonly height: number;
116
+ readonly strideBytes?: number;
117
+ }
118
+ /** A stereo (or mono) calibration. The C value under it never changes: controlSet takes a new one. */
119
+ export declare class Calibration {
120
+ /** @internal */
121
+ _h: NativeHandle;
122
+ /** @internal Use Calibration.fromJson, a source's or a pipeline's calibration. */
123
+ constructor(handle: NativeHandle);
124
+ /** A calibration read from the SDK calibration JSON (contracts/calibration/sdk_json.md). */
125
+ static fromJson(text: string): Calibration;
126
+ /** The SDK calibration JSON. */
127
+ toJson(): string;
128
+ private get info();
129
+ /** "opencv5", "opencv8", "kb4", "eucm", "splined" (contracts/calibration/lens_models.json). */
130
+ get lensModel(): string;
131
+ get isStereo(): boolean;
132
+ /** [width, height] of the eye the calibration is for. */
133
+ get imageSize(): [number, number];
134
+ /** The baseline in metres; NaN for a mono calibration (the C ABI's; the reference: its stored number). */
135
+ get baselineM(): number;
136
+ /** The rectified focal length at the image size, px (a latitude-longitude model: pixels per radian). */
137
+ get focalNativePx(): number;
138
+ /** The canvas's focal length (withCanvas); NaN without a canvas. */
139
+ get focalCanvasPx(): number;
140
+ /** A new calibration for eyes of width x height (the same aspect ratio); no canvas. */
141
+ rescaled(width: number, height: number): Calibration;
142
+ /** The calibration's controls with their values in it. */
143
+ controls(): Control[];
144
+ /** A control's value; undefined for a name it has not. */
145
+ controlGet(name: string): number | string | null | undefined;
146
+ /** Sets a control, coerced as the reference's control_set (clamped, snapped); this calibration
147
+ * takes the new value (the rectification made again). Returns the value in force. */
148
+ controlSet(name: string, value: number | string | boolean): number | string | null | undefined;
149
+ /** A new calibration ready to rectify onto a canvas (its maps, layout and projection). */
150
+ withCanvas(options: CanvasOptions): Calibration;
151
+ /** Where the rectified eye sits in the canvas (no canvas: invalid_state). */
152
+ canvasLayout(): CanvasLayout;
153
+ /** The 3 x 4 projection (row major) of an eye on a pinhole canvas; no eye: the canvas's. */
154
+ canvasProjection(eye?: Eye): number[];
155
+ /** The canvas's remap of an eye in OpenCV's fixed point (CV_16SC2 xy + CV_16UC1 index). */
156
+ canvasMap(eye?: Eye): {
157
+ xy: Int16Array;
158
+ index: Uint16Array;
159
+ };
160
+ /** A raw eye (BGR8) rectified onto the canvas: canvasWidth x canvasHeight BGR8. */
161
+ rectify(eye: Eye | undefined, image: BgrImage): Uint8Array;
162
+ /** Disparity on the canvas (px, width x height) to depth in metres; 0 where d <= 0.1 px. */
163
+ disparityToDepth(disparity: Float32Array, width: number, height: number): Float32Array;
164
+ /** Depth (m) to points (x, y, z per pixel) in the rectified frame of the canvas eye. */
165
+ depthToPointCloud(depth: Float32Array, width: number, height: number): Float32Array;
166
+ /** Releases the C value now (else the garbage collector does). */
167
+ release(): void;
168
+ }