@zappar/zappar-cv 3.0.1-alpha.13 → 3.0.1-alpha.15
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/deserializer.d.ts +1 -0
- package/lib/deserializer.js +9 -0
- package/lib/drawaxis.d.ts +2 -0
- package/lib/drawaxis.js +172 -0
- package/lib/drawgrid.js +3 -0
- package/lib/drawpointswithtype.d.ts +13 -0
- package/lib/drawpointswithtype.js +190 -0
- package/lib/gen/zappar-bridge.d.ts +4 -0
- package/lib/gen/zappar-client.js +51 -5
- package/lib/gen/zappar-cwrap.js +35 -0
- package/lib/gen/zappar-native.d.ts +4 -0
- package/lib/gen/zappar-server.js +20 -4
- package/lib/gen/zappar.d.ts +4 -0
- package/lib/html-element-source.d.ts +3 -0
- package/lib/html-element-source.js +25 -1
- package/lib/serializer.d.ts +1 -0
- package/lib/serializer.js +1 -0
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/lib/worker-server.js +1 -1
- package/lib/zappar-cv.js +1 -1
- package/lib/zappar-cv.wasm +0 -0
- package/package.json +1 -1
- package/umd/751.zappar-cv.js +1 -1
- package/umd/867.zappar-cv.js +1 -1
- package/umd/{7a7455e00ac55a4f34d3.wasm → 97ab16ef8d251feb4f5d.wasm} +0 -0
- package/umd/zappar-cv.js +1 -1
- package/umd/zappar-cv.worker.js +1 -1
package/lib/gen/zappar-server.js
CHANGED
|
@@ -417,7 +417,7 @@ export class zappar_server {
|
|
|
417
417
|
let obj = this._world_tracker_by_instance.get(clientId);
|
|
418
418
|
if (obj === undefined)
|
|
419
419
|
return;
|
|
420
|
-
this._impl.
|
|
420
|
+
this._impl.world_tracker_plane_detection_enabled_set(obj, msg.bool());
|
|
421
421
|
break;
|
|
422
422
|
}
|
|
423
423
|
case 49: {
|
|
@@ -425,10 +425,18 @@ export class zappar_server {
|
|
|
425
425
|
let obj = this._world_tracker_by_instance.get(clientId);
|
|
426
426
|
if (obj === undefined)
|
|
427
427
|
return;
|
|
428
|
-
this._impl.
|
|
428
|
+
this._impl.world_tracker_reset(obj);
|
|
429
429
|
break;
|
|
430
430
|
}
|
|
431
431
|
case 50: {
|
|
432
|
+
let clientId = msg.type();
|
|
433
|
+
let obj = this._world_tracker_by_instance.get(clientId);
|
|
434
|
+
if (obj === undefined)
|
|
435
|
+
return;
|
|
436
|
+
this._impl.world_tracker_tracks_data_enabled_set(obj, msg.bool());
|
|
437
|
+
break;
|
|
438
|
+
}
|
|
439
|
+
case 51: {
|
|
432
440
|
let clientId = msg.type();
|
|
433
441
|
let obj = this._world_tracker_by_instance.get(clientId);
|
|
434
442
|
if (obj === undefined)
|
|
@@ -688,11 +696,19 @@ export class zappar_server {
|
|
|
688
696
|
msg.type(k);
|
|
689
697
|
msg.floatArray(this._impl.world_tracker_tracks_data(v));
|
|
690
698
|
});
|
|
691
|
-
serializer.sendMessage(
|
|
699
|
+
serializer.sendMessage(36, msg => {
|
|
700
|
+
msg.type(k);
|
|
701
|
+
msg.int(this._impl.world_tracker_tracks_type_data_size(v));
|
|
702
|
+
});
|
|
703
|
+
serializer.sendMessage(35, msg => {
|
|
704
|
+
msg.type(k);
|
|
705
|
+
msg.ucharArray(this._impl.world_tracker_tracks_type_data(v));
|
|
706
|
+
});
|
|
707
|
+
serializer.sendMessage(39, msg => {
|
|
692
708
|
msg.type(k);
|
|
693
709
|
msg.int(this._impl.world_tracker_projections_data_size(v));
|
|
694
710
|
});
|
|
695
|
-
serializer.sendMessage(
|
|
711
|
+
serializer.sendMessage(38, msg => {
|
|
696
712
|
msg.type(k);
|
|
697
713
|
msg.floatArray(this._impl.world_tracker_projections_data(v));
|
|
698
714
|
});
|
package/lib/gen/zappar.d.ts
CHANGED
|
@@ -205,6 +205,8 @@ export interface zappar {
|
|
|
205
205
|
world_tracker_enabled(o: zappar_world_tracker_t): boolean;
|
|
206
206
|
world_tracker_enabled_set(o: zappar_world_tracker_t, enabled: boolean): void;
|
|
207
207
|
world_tracker_quality(o: zappar_world_tracker_t): number;
|
|
208
|
+
world_tracker_plane_detection_enabled(o: zappar_world_tracker_t): boolean;
|
|
209
|
+
world_tracker_plane_detection_enabled_set(o: zappar_world_tracker_t, plane_detection_enabled: boolean): void;
|
|
208
210
|
world_tracker_plane_count(o: zappar_world_tracker_t): number;
|
|
209
211
|
world_tracker_plane_pose_raw(o: zappar_world_tracker_t, indx: number): Float32Array;
|
|
210
212
|
world_tracker_plane_pose_camera_relative(o: zappar_world_tracker_t, indx: number, mirror: boolean): Float32Array;
|
|
@@ -222,6 +224,8 @@ export interface zappar {
|
|
|
222
224
|
world_tracker_tracks_data_enabled_set(o: zappar_world_tracker_t, tracks_data_enabled: boolean): void;
|
|
223
225
|
world_tracker_tracks_data_size(o: zappar_world_tracker_t): number;
|
|
224
226
|
world_tracker_tracks_data(o: zappar_world_tracker_t): Float32Array;
|
|
227
|
+
world_tracker_tracks_type_data_size(o: zappar_world_tracker_t): number;
|
|
228
|
+
world_tracker_tracks_type_data(o: zappar_world_tracker_t): Uint8Array;
|
|
225
229
|
world_tracker_projections_data_enabled(o: zappar_world_tracker_t): boolean;
|
|
226
230
|
world_tracker_projections_data_enabled_set(o: zappar_world_tracker_t, projections_data_enabled: boolean): void;
|
|
227
231
|
world_tracker_projections_data_size(o: zappar_world_tracker_t): number;
|
|
@@ -15,6 +15,7 @@ export declare class HTMLElementSource extends Source {
|
|
|
15
15
|
private _cameraToDeviceTransformUserFacing;
|
|
16
16
|
private _cameraModel;
|
|
17
17
|
private _profile;
|
|
18
|
+
private _waitingForFrame;
|
|
18
19
|
static createVideoElementSource(p: zappar_pipeline_t, element: HTMLVideoElement | HTMLImageElement): zappar_html_element_source_t;
|
|
19
20
|
static getVideoElementSource(m: zappar_html_element_source_t): HTMLElementSource | undefined;
|
|
20
21
|
constructor(_video: HTMLVideoElement | HTMLImageElement, _pipeline: zappar_pipeline_t);
|
|
@@ -23,6 +24,8 @@ export declare class HTMLElementSource extends Source {
|
|
|
23
24
|
pause(): void;
|
|
24
25
|
start(): void;
|
|
25
26
|
getFrame(currentlyProcessing: boolean): void;
|
|
27
|
+
private _lastPresentedFrames;
|
|
28
|
+
private _requestVideoFrameCallback;
|
|
26
29
|
private _processFrame;
|
|
27
30
|
uploadGL(): void;
|
|
28
31
|
setProfile(p: camera_profile_t): void;
|
|
@@ -21,6 +21,8 @@ export class HTMLElementSource extends Source {
|
|
|
21
21
|
this._cameraToDeviceTransformUserFacing = mat4.create();
|
|
22
22
|
this._cameraModel = new Float32Array([300, 300, 160, 120, 0, 0]);
|
|
23
23
|
this._profile = camera_profile_t.DEFAULT;
|
|
24
|
+
this._waitingForFrame = false;
|
|
25
|
+
this._lastPresentedFrames = -1;
|
|
24
26
|
mat4.fromScaling(this._cameraToDeviceTransformUserFacing, [-1, 1, -1]);
|
|
25
27
|
let video = this._video;
|
|
26
28
|
if (this._video instanceof HTMLVideoElement) {
|
|
@@ -99,6 +101,25 @@ export class HTMLElementSource extends Source {
|
|
|
99
101
|
}
|
|
100
102
|
return;
|
|
101
103
|
}
|
|
104
|
+
_requestVideoFrameCallback() {
|
|
105
|
+
const video = this._video;
|
|
106
|
+
if (!(video === null || video === void 0 ? void 0 : video.requestVideoFrameCallback))
|
|
107
|
+
return;
|
|
108
|
+
video.requestVideoFrameCallback((time, metadata) => {
|
|
109
|
+
if (typeof metadata === 'object' && typeof metadata.presentedFrames === 'number') {
|
|
110
|
+
if (this._lastPresentedFrames === metadata.presentedFrames) {
|
|
111
|
+
console.log('Avoided identical frame');
|
|
112
|
+
this._requestVideoFrameCallback();
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
this._lastPresentedFrames = metadata.presentedFrames;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
this._waitingForFrame = false;
|
|
120
|
+
});
|
|
121
|
+
this._waitingForFrame = true;
|
|
122
|
+
}
|
|
102
123
|
_processFrame(gl, rotation, currentlyProcessing) {
|
|
103
124
|
let pipeline = Pipeline.get(this._pipeline);
|
|
104
125
|
if (!pipeline)
|
|
@@ -106,12 +127,15 @@ export class HTMLElementSource extends Source {
|
|
|
106
127
|
if (!this._imageProcessor)
|
|
107
128
|
this._imageProcessor = new ImageProcessGL(gl);
|
|
108
129
|
if (this._isUploadFrame) {
|
|
130
|
+
if (this._waitingForFrame)
|
|
131
|
+
return;
|
|
109
132
|
if (!this._currentVideoTexture) {
|
|
110
133
|
this._currentVideoTexture = pipeline.getVideoTexture();
|
|
111
134
|
}
|
|
112
135
|
if (!this._currentVideoTexture)
|
|
113
136
|
return undefined;
|
|
114
137
|
this._imageProcessor.uploadFrame(this._currentVideoTexture, this._video, rotation, this._isUserFacing, this._profile);
|
|
138
|
+
this._requestVideoFrameCallback();
|
|
115
139
|
this._isUploadFrame = !this._isUploadFrame;
|
|
116
140
|
return undefined;
|
|
117
141
|
}
|
|
@@ -131,7 +155,7 @@ export class HTMLElementSource extends Source {
|
|
|
131
155
|
}
|
|
132
156
|
let tex = this._currentVideoTexture;
|
|
133
157
|
this._currentVideoTexture = undefined;
|
|
134
|
-
let focalLength =
|
|
158
|
+
let focalLength = 240.0 * dataWidth / 320.0;
|
|
135
159
|
this._cameraModel[0] = focalLength;
|
|
136
160
|
this._cameraModel[1] = focalLength;
|
|
137
161
|
this._cameraModel[2] = dataWidth * 0.5;
|
package/lib/serializer.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export interface MessageAppender {
|
|
|
8
8
|
type: (t: number) => void;
|
|
9
9
|
matrix4x4: (a: Float32Array) => void;
|
|
10
10
|
matrix3x3: (a: Float32Array) => void;
|
|
11
|
+
ucharArray: (a: Uint8Array) => void;
|
|
11
12
|
floatArray: (a: Float32Array) => void;
|
|
12
13
|
cameraModel: (a: Float32Array) => void;
|
|
13
14
|
identityCoefficients: (a: Float32Array) => void;
|
package/lib/serializer.js
CHANGED
|
@@ -23,6 +23,7 @@ export class MessageSerializer {
|
|
|
23
23
|
matrix4x4: i => this.float32ArrayBuffer(i),
|
|
24
24
|
matrix3x3: i => this.float32ArrayBuffer(i),
|
|
25
25
|
floatArray: i => this.float32ArrayBuffer(i),
|
|
26
|
+
ucharArray: i => this.uint8ArrayBuffer(i),
|
|
26
27
|
identityCoefficients: i => this.float32ArrayBuffer(i),
|
|
27
28
|
expressionCoefficients: i => this.float32ArrayBuffer(i),
|
|
28
29
|
cameraModel: i => this.float32ArrayBuffer(i),
|
package/lib/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "3.0.1-alpha.
|
|
1
|
+
export declare const VERSION = "3.0.1-alpha.15";
|
package/lib/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "3.0.1-alpha.
|
|
1
|
+
export const VERSION = "3.0.1-alpha.15";
|
package/lib/worker-server.js
CHANGED
|
@@ -266,7 +266,7 @@ function consumeReader(mod, r, reader, p, userFacing, server, source, workerMess
|
|
|
266
266
|
mat4.fromScaling(cameraToDeviceTransform, [-1, 1, -1]);
|
|
267
267
|
else
|
|
268
268
|
mat4.identity(cameraToDeviceTransform);
|
|
269
|
-
let focalLength =
|
|
269
|
+
let focalLength = 240.0 * dataWidth / 320.0;
|
|
270
270
|
cameraModel[0] = focalLength;
|
|
271
271
|
cameraModel[1] = focalLength;
|
|
272
272
|
cameraModel[2] = dataWidth * 0.5;
|