@zappar/zappar-cv 3.3.0-beta.2 → 3.4.0-beta.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/README.md +2 -2
- package/lib/bridged-camera-source.d.ts +2 -0
- package/lib/bridged-camera-source.js +13 -0
- package/lib/bridged-message.d.ts +1 -0
- package/lib/bridged-world-tracker.js +8 -6
- package/lib/ceres-worker.d.ts +1 -1
- package/lib/ceres-worker.js +5 -5
- package/lib/gen/zappar-bridge.d.ts +3 -1
- package/lib/gen/zappar-client.js +100 -71
- package/lib/gen/zappar-cwrap.js +27 -6
- package/lib/gen/zappar-native.d.ts +6 -3
- package/lib/gen/zappar-native.js +1 -0
- package/lib/gen/zappar-server.js +80 -68
- package/lib/gen/zappar.d.ts +3 -1
- package/lib/html-element-source.js +3 -4
- package/lib/index-standalone.js +1 -1
- package/lib/mstp-camera-source.d.ts +3 -0
- package/lib/mstp-camera-source.js +21 -0
- package/lib/native.js +20 -14
- package/lib/options.d.ts +2 -1
- package/lib/pipeline.d.ts +1 -0
- package/lib/pipeline.js +13 -0
- package/lib/profile.js +1 -2
- package/lib/src/additional.d.ts +49 -0
- package/lib/src/android-bridge-message-handler.d.ts +15 -0
- package/lib/src/array-from-string.d.ts +2 -0
- package/lib/src/bridged-camera-source.d.ts +53 -0
- package/lib/src/bridged-d3-tracker.d.ts +18 -0
- package/lib/src/bridged-message-parser.d.ts +12 -0
- package/lib/src/bridged-message.d.ts +79 -0
- package/lib/src/bridged-world-tracker.d.ts +21 -0
- package/lib/src/camera-frame-data.d.ts +10 -0
- package/lib/src/camera-source-map.d.ts +11 -0
- package/lib/src/camera-source.d.ts +28 -0
- package/lib/src/cameramodel.d.ts +2 -0
- package/lib/src/ceres-worker.d.ts +1 -0
- package/lib/src/compatibility.d.ts +5 -0
- package/lib/src/data-download.d.ts +8 -0
- package/lib/src/deserializer.d.ts +41 -0
- package/lib/src/direct.d.ts +3 -0
- package/lib/src/drawaxis.d.ts +2 -0
- package/lib/src/drawcamera.d.ts +12 -0
- package/lib/src/drawface.d.ts +16 -0
- package/lib/src/drawfaceproject.d.ts +15 -0
- package/lib/src/drawgrid.d.ts +2 -0
- package/lib/src/drawmesh.d.ts +14 -0
- package/lib/src/drawplane.d.ts +2 -0
- package/lib/src/drawpoints.d.ts +11 -0
- package/lib/src/drawpointswithtype.d.ts +13 -0
- package/lib/src/drawpolygon.d.ts +5 -0
- package/lib/src/drawpreviewmesh.d.ts +16 -0
- package/lib/src/drawquad.d.ts +2 -0
- package/lib/src/event.d.ts +30 -0
- package/lib/src/facelandmark.d.ts +11 -0
- package/lib/src/facelandmarkdata.d.ts +4 -0
- package/lib/src/facelandmarkinterface.d.ts +5 -0
- package/lib/src/facemesh.d.ts +27 -0
- package/lib/src/gen/zappar-bridge.d.ts +182 -0
- package/lib/src/gen/zappar-client.d.ts +26 -0
- package/lib/src/gen/zappar-cwrap.d.ts +12 -0
- package/lib/src/gen/zappar-native.d.ts +256 -0
- package/lib/src/gen/zappar-server.d.ts +50 -0
- package/lib/src/gen/zappar.d.ts +311 -0
- package/lib/src/gfx.d.ts +1 -0
- package/lib/src/gl-state-manager.d.ts +9 -0
- package/lib/src/html-element-source.d.ts +42 -0
- package/lib/src/image-process-gl.d.ts +40 -0
- package/lib/src/imagebitmap-camera-source.d.ts +39 -0
- package/lib/src/imagetracker-previewmesh.d.ts +2 -0
- package/lib/src/imagetracker.d.ts +43 -0
- package/lib/src/index-standalone.d.ts +3 -0
- package/lib/src/index.d.ts +7 -0
- package/lib/src/landmarkdatagenerate.d.ts +2 -0
- package/lib/src/loglevel.d.ts +5 -0
- package/lib/src/messages.d.ts +13 -0
- package/lib/src/mstp-camera-source.d.ts +44 -0
- package/lib/src/native.d.ts +3 -0
- package/lib/src/options.d.ts +5 -0
- package/lib/src/permission.d.ts +12 -0
- package/lib/src/pipeline.d.ts +88 -0
- package/lib/src/profile.d.ts +24 -0
- package/lib/src/riff-reader.d.ts +18 -0
- package/lib/src/sequencerecorder.d.ts +99 -0
- package/lib/src/sequencesource.d.ts +25 -0
- package/lib/src/serializer.d.ts +60 -0
- package/lib/src/shader.d.ts +2 -0
- package/lib/src/source.d.ts +22 -0
- package/lib/src/tr.d.ts +6 -0
- package/lib/src/tracing/jsontracer.d.ts +14 -0
- package/lib/src/tracing/performancetracer.d.ts +11 -0
- package/lib/src/tracing/sharedtracer.d.ts +2 -0
- package/lib/src/tracing/usertimingtracer.d.ts +10 -0
- package/lib/src/version.d.ts +1 -0
- package/lib/src/worker-client.d.ts +4 -0
- package/lib/src/worker-imagebitmap.d.ts +5 -0
- package/lib/src/worker-messages.d.ts +11 -0
- package/lib/src/worker-server.d.ts +3 -0
- package/lib/src/worker.d.ts +1 -0
- package/lib/src/workerinterface.d.ts +110 -0
- package/lib/src/yuv-conversion-gl.d.ts +44 -0
- package/lib/tests/barcode-finder.d.ts +1 -0
- package/lib/tests/camera-data-raw.d.ts +1 -0
- package/lib/tests/camera-data-rgb.d.ts +1 -0
- package/lib/tests/camera-far-near.d.ts +1 -0
- package/lib/tests/camera-only.d.ts +1 -0
- package/lib/tests/common.d.ts +15 -0
- package/lib/tests/d3-tracking.d.ts +1 -0
- package/lib/tests/drawanchor.d.ts +3 -0
- package/lib/tests/face-landmarks.d.ts +1 -0
- package/lib/tests/face-tracking.d.ts +1 -0
- package/lib/tests/image-tracking-cylinder.d.ts +1 -0
- package/lib/tests/image-tracking-preview-mesh.d.ts +1 -0
- package/lib/tests/image-tracking.d.ts +1 -0
- package/lib/tests/instant-tracking.d.ts +1 -0
- package/lib/tests/no-rendering.d.ts +1 -0
- package/lib/tests/sequence-preview.d.ts +1 -0
- package/lib/tests/two-pipelines.d.ts +1 -0
- package/lib/tests/video-face-tracking.d.ts +1 -0
- package/lib/tests/world-tracking-camera-offset-anchor.d.ts +1 -0
- package/lib/tests/world-tracking-meshes.d.ts +1 -0
- package/lib/tests/world-tracking-plane-offset-anchor.d.ts +1 -0
- package/lib/tests/world-tracking.d.ts +1 -0
- package/lib/tests/zapcode-tracking.d.ts +1 -0
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/lib/worker-client.d.ts +1 -1
- package/lib/worker-client.js +23 -9
- package/lib/worker-messages.d.ts +2 -1
- package/lib/worker-messages.js +2 -1
- package/lib/worker-server.js +27 -10
- package/lib/workerinterface.d.ts +2 -1
- package/lib/zappar-cv.js +1 -1
- package/lib/zappar-cv.wasm +0 -0
- package/package.json +2 -4
- package/umd/169.zappar-cv.js +0 -1
- package/umd/25.zappar-cv.js +0 -1
- package/umd/287.zappar-cv.js +0 -1
- package/umd/482727c0e7dd40d73f5a.zbin +0 -0
- package/umd/670905e7f3a8925b89cb.wasm +0 -0
- package/umd/867.zappar-cv.js +0 -1
- package/umd/b4f46e148a3b3b5aef90.zbin +0 -0
- package/umd/f7b62a3a53b5c9b3222b.zbin +0 -0
- package/umd/zappar-cv-ceres.worker.js +0 -1
- package/umd/zappar-cv.js +0 -1
- package/umd/zappar-cv.worker.js +0 -1
package/README.md
CHANGED
|
@@ -18,8 +18,8 @@ npm i @zappar/zappar-cv
|
|
|
18
18
|
|
|
19
19
|
You can use our CDN from within your HTML:
|
|
20
20
|
```
|
|
21
|
-
<script src="https://libs.zappar.com/zappar-cv/3.
|
|
21
|
+
<script src="https://libs.zappar.com/zappar-cv/3.4.0-beta.1/zappar-cv.js"></script>
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
Or you can download and host our standalone JavaScript bundle:
|
|
25
|
-
[https://libs.zappar.com/zappar-cv/3.
|
|
25
|
+
[https://libs.zappar.com/zappar-cv/3.4.0-beta.1/zappar-cv.zip](https://libs.zappar.com/zappar-cv/3.4.0-beta.1/zappar-cv.zip)
|
|
@@ -26,6 +26,8 @@ export declare class BridgedCameraSource extends Source {
|
|
|
26
26
|
private _yuvConversion;
|
|
27
27
|
private _decodeBuffers;
|
|
28
28
|
private _options;
|
|
29
|
+
private static _resetCount;
|
|
30
|
+
private _isAndroid;
|
|
29
31
|
static IsSupported(): boolean;
|
|
30
32
|
constructor(_impl: zappar_camera_source_t, _pipeline: zappar_pipeline_t, _deviceId: string);
|
|
31
33
|
destroy(): void;
|
|
@@ -46,6 +46,7 @@ export class BridgedCameraSource extends Source {
|
|
|
46
46
|
this._textureSizes = new Map();
|
|
47
47
|
this._decodeBuffers = [];
|
|
48
48
|
this._options = {};
|
|
49
|
+
this._isAndroid = false; // iOS resets on start, Android only on stop
|
|
49
50
|
this._frameInFlight = false;
|
|
50
51
|
this._anchorPoseFloat32 = new Float32Array(16);
|
|
51
52
|
this._anchorPoseUint16 = new Uint16Array(this._anchorPoseFloat32.buffer);
|
|
@@ -98,6 +99,7 @@ export class BridgedCameraSource extends Source {
|
|
|
98
99
|
};
|
|
99
100
|
if (AndroidBridgeMessageHandler.IsSupported()) {
|
|
100
101
|
this._messageHandler = AndroidBridgeMessageHandler.SharedInstance();
|
|
102
|
+
this._isAndroid = true;
|
|
101
103
|
}
|
|
102
104
|
else {
|
|
103
105
|
this._messageHandler = (_b = (_a = window.webkit) === null || _a === void 0 ? void 0 : _a.messageHandlers) === null || _b === void 0 ? void 0 : _b.bridgedCamera;
|
|
@@ -123,6 +125,8 @@ export class BridgedCameraSource extends Source {
|
|
|
123
125
|
p.currentCameraSource = undefined;
|
|
124
126
|
this._decodeBuffers = [];
|
|
125
127
|
this._stopDeviceMotion();
|
|
128
|
+
if (this._isAndroid)
|
|
129
|
+
BridgedCameraSource._resetCount++;
|
|
126
130
|
this._messageHandler.postMessage("stop");
|
|
127
131
|
}
|
|
128
132
|
start() {
|
|
@@ -139,6 +143,8 @@ export class BridgedCameraSource extends Source {
|
|
|
139
143
|
if (p) {
|
|
140
144
|
options = Object.assign(Object.assign({}, BridgedWorldTracker.SharedInstance().getCombinedOptionsForPipeline(p)), BridgedD3Tracker.SharedInstance().getCombinedOptionsForPipeline(p));
|
|
141
145
|
}
|
|
146
|
+
if (!this._isAndroid)
|
|
147
|
+
BridgedCameraSource._resetCount++;
|
|
142
148
|
this._messageHandler.postMessage(`start${this._convertToBitmask(options)}:${this._profile}`);
|
|
143
149
|
}
|
|
144
150
|
getFrame(currentlyProcessing) {
|
|
@@ -223,6 +229,10 @@ export class BridgedCameraSource extends Source {
|
|
|
223
229
|
if (frameInfo.cameraModel) {
|
|
224
230
|
this._cameraModel.set(frameInfo.cameraModel);
|
|
225
231
|
}
|
|
232
|
+
if (!('session_number' in frameInfo.wtData)) {
|
|
233
|
+
// Fill in session_number with the fallback value
|
|
234
|
+
frameInfo.wtData.session_number = BridgedCameraSource._resetCount;
|
|
235
|
+
}
|
|
226
236
|
traceStart(`Prepare CameraFrameInfo ${frameInfo.frameNo || 0}`);
|
|
227
237
|
let numDataBytes = frameInfo.dataWidth * frameInfo.dataHeight;
|
|
228
238
|
let pixels = pipeline.cameraPixelArrays.pop();
|
|
@@ -369,6 +379,7 @@ export class BridgedCameraSource extends Source {
|
|
|
369
379
|
this._messageHandler.postMessage(message);
|
|
370
380
|
}
|
|
371
381
|
resetTracking() {
|
|
382
|
+
BridgedCameraSource._resetCount++;
|
|
372
383
|
this._messageHandler.postMessage('resetTracking');
|
|
373
384
|
}
|
|
374
385
|
_convertToBitmask(options) {
|
|
@@ -404,3 +415,5 @@ export class BridgedCameraSource extends Source {
|
|
|
404
415
|
}
|
|
405
416
|
}
|
|
406
417
|
BridgedCameraSource.DEFAULT_DEVICE_ID = "Simulated Default Device ID: a908df7f-5661-4d20-b227-a1c15d2fdb4b";
|
|
418
|
+
// Fallback for session_number if native side doesn't fill it in
|
|
419
|
+
BridgedCameraSource._resetCount = 0;
|
package/lib/bridged-message.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { anchor_status_t, world_tracker_quality_t } from './gen/zappar-native';
|
|
2
2
|
import { UvLayout } from './yuv-conversion-gl';
|
|
3
3
|
export interface WTData {
|
|
4
|
+
session_number?: number;
|
|
4
5
|
world_anchor_status: anchor_status_t;
|
|
5
6
|
world_anchor_pose: Float32Array | number[];
|
|
6
7
|
ground_anchor_status: anchor_status_t;
|
|
@@ -43,10 +43,17 @@ export class BridgedWorldTracker {
|
|
|
43
43
|
s.enabled = enabled;
|
|
44
44
|
this._notifyOptionsUpdated(s.pipeline);
|
|
45
45
|
},
|
|
46
|
+
world_tracker_session_number: (o) => {
|
|
47
|
+
let wtData = this._getWtData(o);
|
|
48
|
+
let s = wtData === null || wtData === void 0 ? void 0 : wtData.session_number;
|
|
49
|
+
if (s === undefined)
|
|
50
|
+
return 0;
|
|
51
|
+
return s;
|
|
52
|
+
},
|
|
46
53
|
world_tracker_quality: (o) => {
|
|
47
54
|
let wtData = this._getWtData(o);
|
|
48
55
|
if (!wtData)
|
|
49
|
-
return
|
|
56
|
+
return 3;
|
|
50
57
|
return wtData.quality;
|
|
51
58
|
},
|
|
52
59
|
world_tracker_horizontal_plane_detection_enabled: (o) => {
|
|
@@ -157,11 +164,6 @@ export class BridgedWorldTracker {
|
|
|
157
164
|
return pose;
|
|
158
165
|
},
|
|
159
166
|
world_tracker_reset: (o) => {
|
|
160
|
-
// Reset local pose_version state
|
|
161
|
-
for (const entry of this._anchorStateById.values()) {
|
|
162
|
-
if (entry.wt === o)
|
|
163
|
-
entry.pose_version = 0;
|
|
164
|
-
}
|
|
165
167
|
let s = this._getWtState(o);
|
|
166
168
|
let source = s.pipeline.currentCameraSource;
|
|
167
169
|
if (source instanceof BridgedCameraSource) {
|
package/lib/ceres-worker.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function launchCeresWorker(wasmUrl: string, module: WebAssembly.Module, port: MessagePort): Promise<void>;
|
|
1
|
+
export declare function launchCeresWorker(wasmUrl: string, module: WebAssembly.Module, port: MessagePort, instance: number): Promise<void>;
|
package/lib/ceres-worker.js
CHANGED
|
@@ -13,12 +13,12 @@ const ctx = self;
|
|
|
13
13
|
let launchHandler = (evt) => {
|
|
14
14
|
if (evt && evt.data && evt.data.t === "wasm") {
|
|
15
15
|
let url = location.href.startsWith("blob") ? evt.data.url : new URL("./zappar-cv.wasm", import.meta.url).toString();
|
|
16
|
-
launchCeresWorker(url, evt.data.module, evt.data.port);
|
|
16
|
+
launchCeresWorker(url, evt.data.module, evt.data.port, evt.data.instance);
|
|
17
17
|
ctx.removeEventListener("message", launchHandler);
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
20
|
ctx.addEventListener("message", launchHandler);
|
|
21
|
-
export function launchCeresWorker(wasmUrl, module, port) {
|
|
21
|
+
export function launchCeresWorker(wasmUrl, module, port, instance) {
|
|
22
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
23
23
|
let mod = ZNM.default({
|
|
24
24
|
locateFile: (path, prefix) => {
|
|
@@ -33,7 +33,7 @@ export function launchCeresWorker(wasmUrl, module, port) {
|
|
|
33
33
|
return instance.exports;
|
|
34
34
|
},
|
|
35
35
|
onRuntimeInitialized: () => {
|
|
36
|
-
const ceres_worker = mod.cwrap('ceres_worker', null, []);
|
|
36
|
+
const ceres_worker = mod.cwrap('ceres_worker', null, ['number']);
|
|
37
37
|
const messageAPI = getWorkerMessageAPI(mod);
|
|
38
38
|
port.addEventListener('message', evt => {
|
|
39
39
|
if (evt.data.t !== 'msgsend')
|
|
@@ -42,9 +42,9 @@ export function launchCeresWorker(wasmUrl, module, port) {
|
|
|
42
42
|
const reference = evt.data.reference;
|
|
43
43
|
const ptr = mod._malloc(data.byteLength);
|
|
44
44
|
mod.HEAPU8.set(data, ptr);
|
|
45
|
-
messageAPI.worker_message_receive(reference, data.byteLength, ptr);
|
|
45
|
+
messageAPI.worker_message_receive(reference, data.byteLength, ptr, instance);
|
|
46
46
|
mod._free(ptr);
|
|
47
|
-
ceres_worker();
|
|
47
|
+
ceres_worker(instance);
|
|
48
48
|
const toSend = messageAPI.worker_message_send_count();
|
|
49
49
|
for (let i = 0; i < toSend; i++) {
|
|
50
50
|
const reference = messageAPI.worker_message_send_reference(i);
|
|
@@ -67,7 +67,7 @@ export interface zappar {
|
|
|
67
67
|
pipeline_camera_data_width(o: zappar_pipeline_t): number;
|
|
68
68
|
pipeline_camera_data_height(o: zappar_pipeline_t): number;
|
|
69
69
|
pipeline_camera_frame_user_data(o: zappar_pipeline_t): number;
|
|
70
|
-
pipeline_camera_frame_submit(o: zappar_pipeline_t, data: ArrayBuffer, width: number, height: number, user_data: number, camera_to_device_transform: Float32Array, camera_model: Float32Array, user_facing: boolean,
|
|
70
|
+
pipeline_camera_frame_submit(o: zappar_pipeline_t, data: ArrayBuffer, width: number, height: number, user_data: number, camera_to_device_transform: Float32Array, camera_model: Float32Array, user_facing: boolean, timestampMicroseconds: number): void;
|
|
71
71
|
pipeline_camera_frame_camera_attitude(o: zappar_pipeline_t): Float32Array;
|
|
72
72
|
pipeline_camera_frame_device_attitude(o: zappar_pipeline_t): Float32Array;
|
|
73
73
|
pipeline_motion_accelerometer_submit(o: zappar_pipeline_t, time: number, x: number, y: number, z: number): void;
|
|
@@ -77,6 +77,7 @@ export interface zappar {
|
|
|
77
77
|
pipeline_motion_rotation_rate_submit_int(o: zappar_pipeline_t, time: number, interval: number, x: number, y: number, z: number): void;
|
|
78
78
|
pipeline_motion_attitude_submit(o: zappar_pipeline_t, time: number, x: number, y: number, z: number): void;
|
|
79
79
|
pipeline_motion_attitude_submit_int(o: zappar_pipeline_t, time: number, interval: number, x: number, y: number, z: number): void;
|
|
80
|
+
pipeline_motion_relative_orientation_submit_int(o: zappar_pipeline_t, time: number, interval: number, x: number, y: number, z: number, w: number): void;
|
|
80
81
|
pipeline_motion_attitude_matrix_submit(o: zappar_pipeline_t, mat: Float32Array): void;
|
|
81
82
|
camera_source_create(pipeline: zappar_pipeline_t, device_id: string): zappar_camera_source_t;
|
|
82
83
|
camera_source_destroy(o: zappar_camera_source_t): void;
|
|
@@ -136,6 +137,7 @@ export interface zappar {
|
|
|
136
137
|
world_tracker_destroy(o: zappar_world_tracker_t): void;
|
|
137
138
|
world_tracker_enabled(o: zappar_world_tracker_t): boolean;
|
|
138
139
|
world_tracker_enabled_set(o: zappar_world_tracker_t, enabled: boolean): void;
|
|
140
|
+
world_tracker_session_number(o: zappar_world_tracker_t): number;
|
|
139
141
|
world_tracker_quality(o: zappar_world_tracker_t): number;
|
|
140
142
|
world_tracker_horizontal_plane_detection_enabled(o: zappar_world_tracker_t): boolean;
|
|
141
143
|
world_tracker_horizontal_plane_detection_enabled_set(o: zappar_world_tracker_t, horizontal_plane_detection_enabled: boolean): void;
|