@zappar/zappar-cv 3.0.1-alpha.14 → 3.0.1-alpha.16

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.
@@ -237,6 +237,13 @@ export function getRuntimeObject(mod) {
237
237
  let world_tracker_quality_wrapped = mod.cwrap("zappar_world_tracker_quality", "number", [
238
238
  "number"
239
239
  ]);
240
+ let world_tracker_plane_detection_enabled_wrapped = mod.cwrap("zappar_world_tracker_plane_detection_enabled", "number", [
241
+ "number"
242
+ ]);
243
+ let world_tracker_plane_detection_enabled_set_wrapped = mod.cwrap("zappar_world_tracker_plane_detection_enabled_set", null, [
244
+ "number",
245
+ "number"
246
+ ]);
240
247
  let world_tracker_plane_count_wrapped = mod.cwrap("zappar_world_tracker_plane_count", "number", [
241
248
  "number"
242
249
  ]);
@@ -244,6 +251,18 @@ export function getRuntimeObject(mod) {
244
251
  "number",
245
252
  "number"
246
253
  ]);
254
+ let world_tracker_plane_visible_wrapped = mod.cwrap("zappar_world_tracker_plane_visible", "number", [
255
+ "number",
256
+ "number"
257
+ ]);
258
+ let world_tracker_plane_polygon_data_size_wrapped = mod.cwrap("zappar_world_tracker_plane_polygon_data_size", "number", [
259
+ "number",
260
+ "number"
261
+ ]);
262
+ let world_tracker_plane_polygon_data_wrapped = mod.cwrap("zappar_world_tracker_plane_polygon_data", "number", [
263
+ "number",
264
+ "number"
265
+ ]);
247
266
  let world_tracker_world_anchor_valid_wrapped = mod.cwrap("zappar_world_tracker_world_anchor_valid", "number", [
248
267
  "number"
249
268
  ]);
@@ -272,6 +291,12 @@ export function getRuntimeObject(mod) {
272
291
  let world_tracker_tracks_data_wrapped = mod.cwrap("zappar_world_tracker_tracks_data", "number", [
273
292
  "number"
274
293
  ]);
294
+ let world_tracker_tracks_type_data_size_wrapped = mod.cwrap("zappar_world_tracker_tracks_type_data_size", "number", [
295
+ "number"
296
+ ]);
297
+ let world_tracker_tracks_type_data_wrapped = mod.cwrap("zappar_world_tracker_tracks_type_data", "number", [
298
+ "number"
299
+ ]);
275
300
  let world_tracker_projections_data_enabled_wrapped = mod.cwrap("zappar_world_tracker_projections_data_enabled", "number", [
276
301
  "number"
277
302
  ]);
@@ -771,6 +796,16 @@ export function getRuntimeObject(mod) {
771
796
  let ret = world_tracker_quality_wrapped(o);
772
797
  return ret;
773
798
  },
799
+ world_tracker_plane_detection_enabled: (o) => {
800
+ let ret = world_tracker_plane_detection_enabled_wrapped(o);
801
+ ret = ret === 1;
802
+ return ret;
803
+ },
804
+ world_tracker_plane_detection_enabled_set: (o, plane_detection_enabled) => {
805
+ let arg_plane_detection_enabled = plane_detection_enabled ? 1 : 0;
806
+ let ret = world_tracker_plane_detection_enabled_set_wrapped(o, arg_plane_detection_enabled);
807
+ return ret;
808
+ },
774
809
  world_tracker_plane_count: (o) => {
775
810
  let ret = world_tracker_plane_count_wrapped(o);
776
811
  return ret;
@@ -783,6 +818,26 @@ export function getRuntimeObject(mod) {
783
818
  ret = ab;
784
819
  return ret;
785
820
  },
821
+ world_tracker_plane_visible: (o, indx) => {
822
+ let arg_indx = indx;
823
+ let ret = world_tracker_plane_visible_wrapped(o, arg_indx);
824
+ ret = ret === 1;
825
+ return ret;
826
+ },
827
+ world_tracker_plane_polygon_data_size: (o, indx) => {
828
+ let arg_indx = indx;
829
+ let ret = world_tracker_plane_polygon_data_size_wrapped(o, arg_indx);
830
+ return ret;
831
+ },
832
+ world_tracker_plane_polygon_data: (o, indx) => {
833
+ let arg_indx = indx;
834
+ let ret = world_tracker_plane_polygon_data_wrapped(o, arg_indx);
835
+ let retsize = world_tracker_plane_polygon_data_size_wrapped(o, indx);
836
+ let ab = new Float32Array(retsize);
837
+ ab.set(mod.HEAPF32.subarray(ret / 4, retsize + ret / 4));
838
+ ret = ab;
839
+ return ret;
840
+ },
786
841
  world_tracker_world_anchor_valid: (o) => {
787
842
  let ret = world_tracker_world_anchor_valid_wrapped(o);
788
843
  ret = ret === 1;
@@ -833,6 +888,18 @@ export function getRuntimeObject(mod) {
833
888
  ret = ab;
834
889
  return ret;
835
890
  },
891
+ world_tracker_tracks_type_data_size: (o) => {
892
+ let ret = world_tracker_tracks_type_data_size_wrapped(o);
893
+ return ret;
894
+ },
895
+ world_tracker_tracks_type_data: (o) => {
896
+ let ret = world_tracker_tracks_type_data_wrapped(o);
897
+ let retsize = world_tracker_tracks_type_data_size_wrapped(o);
898
+ let ab = new Uint8Array(retsize);
899
+ ab.set(mod.HEAPU8.subarray(ret, retsize + ret));
900
+ ret = ab;
901
+ return ret;
902
+ },
836
903
  world_tracker_projections_data_enabled: (o) => {
837
904
  let ret = world_tracker_projections_data_enabled_wrapped(o);
838
905
  ret = ret === 1;
@@ -188,8 +188,13 @@ export interface zappar_cwrap {
188
188
  world_tracker_enabled(o: zappar_world_tracker_t): boolean;
189
189
  world_tracker_enabled_set(o: zappar_world_tracker_t, enabled: boolean): void;
190
190
  world_tracker_quality(o: zappar_world_tracker_t): number;
191
+ world_tracker_plane_detection_enabled(o: zappar_world_tracker_t): boolean;
192
+ world_tracker_plane_detection_enabled_set(o: zappar_world_tracker_t, plane_detection_enabled: boolean): void;
191
193
  world_tracker_plane_count(o: zappar_world_tracker_t): number;
192
194
  world_tracker_plane_pose_raw(o: zappar_world_tracker_t, indx: number): Float32Array;
195
+ world_tracker_plane_visible(o: zappar_world_tracker_t, indx: number): boolean;
196
+ world_tracker_plane_polygon_data_size(o: zappar_world_tracker_t, indx: number): number;
197
+ world_tracker_plane_polygon_data(o: zappar_world_tracker_t, indx: number): Float32Array;
193
198
  world_tracker_world_anchor_valid(o: zappar_world_tracker_t): boolean;
194
199
  world_tracker_world_anchor_pose_raw(o: zappar_world_tracker_t): Float32Array;
195
200
  world_tracker_ground_anchor_valid(o: zappar_world_tracker_t): boolean;
@@ -199,6 +204,8 @@ export interface zappar_cwrap {
199
204
  world_tracker_tracks_data_enabled_set(o: zappar_world_tracker_t, tracks_data_enabled: boolean): void;
200
205
  world_tracker_tracks_data_size(o: zappar_world_tracker_t): number;
201
206
  world_tracker_tracks_data(o: zappar_world_tracker_t): Float32Array;
207
+ world_tracker_tracks_type_data_size(o: zappar_world_tracker_t): number;
208
+ world_tracker_tracks_type_data(o: zappar_world_tracker_t): Uint8Array;
202
209
  world_tracker_projections_data_enabled(o: zappar_world_tracker_t): boolean;
203
210
  world_tracker_projections_data_enabled_set(o: zappar_world_tracker_t, projections_data_enabled: boolean): void;
204
211
  world_tracker_projections_data_size(o: zappar_world_tracker_t): number;
@@ -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.world_tracker_reset(obj);
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.world_tracker_tracks_data_enabled_set(obj, msg.bool());
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)
@@ -649,7 +657,7 @@ export class zappar_server {
649
657
  let serializer = this.serializersByPipelineId.get(pipeline);
650
658
  if (!serializer)
651
659
  continue;
652
- serializer.sendMessage(31, msg => {
660
+ serializer.sendMessage(34, msg => {
653
661
  msg.type(k);
654
662
  msg.int(this._impl.world_tracker_quality(v));
655
663
  });
@@ -664,35 +672,64 @@ export class zappar_server {
664
672
  msg.matrix4x4(this._impl.world_tracker_plane_pose_raw(v, i));
665
673
  });
666
674
  }
667
- serializer.sendMessage(27, msg => {
675
+ for (let i = 0; i < this._impl.world_tracker_plane_count(v); i++) {
676
+ serializer.sendMessage(27, msg => {
677
+ msg.type(k);
678
+ msg.int(i);
679
+ msg.bool(this._impl.world_tracker_plane_visible(v, i));
680
+ });
681
+ }
682
+ for (let i = 0; i < this._impl.world_tracker_plane_count(v); i++) {
683
+ serializer.sendMessage(28, msg => {
684
+ msg.type(k);
685
+ msg.int(i);
686
+ msg.int(this._impl.world_tracker_plane_polygon_data_size(v, i));
687
+ });
688
+ }
689
+ for (let i = 0; i < this._impl.world_tracker_plane_count(v); i++) {
690
+ serializer.sendMessage(29, msg => {
691
+ msg.type(k);
692
+ msg.int(i);
693
+ msg.floatArray(this._impl.world_tracker_plane_polygon_data(v, i));
694
+ });
695
+ }
696
+ serializer.sendMessage(30, msg => {
668
697
  msg.type(k);
669
698
  msg.bool(this._impl.world_tracker_world_anchor_valid(v));
670
699
  });
671
- serializer.sendMessage(28, msg => {
700
+ serializer.sendMessage(31, msg => {
672
701
  msg.type(k);
673
702
  msg.matrix4x4(this._impl.world_tracker_world_anchor_pose_raw(v));
674
703
  });
675
- serializer.sendMessage(27, msg => {
704
+ serializer.sendMessage(30, msg => {
676
705
  msg.type(k);
677
706
  msg.bool(this._impl.world_tracker_ground_anchor_valid(v));
678
707
  });
679
- serializer.sendMessage(30, msg => {
708
+ serializer.sendMessage(33, msg => {
680
709
  msg.type(k);
681
710
  msg.matrix4x4(this._impl.world_tracker_ground_anchor_pose_raw(v));
682
711
  });
683
- serializer.sendMessage(34, msg => {
712
+ serializer.sendMessage(37, msg => {
684
713
  msg.type(k);
685
714
  msg.int(this._impl.world_tracker_tracks_data_size(v));
686
715
  });
687
- serializer.sendMessage(33, msg => {
716
+ serializer.sendMessage(36, msg => {
688
717
  msg.type(k);
689
718
  msg.floatArray(this._impl.world_tracker_tracks_data(v));
690
719
  });
691
- serializer.sendMessage(37, msg => {
720
+ serializer.sendMessage(39, msg => {
721
+ msg.type(k);
722
+ msg.int(this._impl.world_tracker_tracks_type_data_size(v));
723
+ });
724
+ serializer.sendMessage(38, msg => {
725
+ msg.type(k);
726
+ msg.ucharArray(this._impl.world_tracker_tracks_type_data(v));
727
+ });
728
+ serializer.sendMessage(42, msg => {
692
729
  msg.type(k);
693
730
  msg.int(this._impl.world_tracker_projections_data_size(v));
694
731
  });
695
- serializer.sendMessage(36, msg => {
732
+ serializer.sendMessage(41, msg => {
696
733
  msg.type(k);
697
734
  msg.floatArray(this._impl.world_tracker_projections_data(v));
698
735
  });
@@ -205,10 +205,15 @@ 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;
212
+ world_tracker_plane_visible(o: zappar_world_tracker_t, indx: number): boolean;
210
213
  world_tracker_plane_pose_camera_relative(o: zappar_world_tracker_t, indx: number, mirror: boolean): Float32Array;
211
214
  world_tracker_plane_pose(o: zappar_world_tracker_t, indx: number, camera_pose: Float32Array, mirror: boolean): Float32Array;
215
+ world_tracker_plane_polygon_data_size(o: zappar_world_tracker_t, indx: number): number;
216
+ world_tracker_plane_polygon_data(o: zappar_world_tracker_t, indx: number): Float32Array;
212
217
  world_tracker_world_anchor_valid(o: zappar_world_tracker_t): boolean;
213
218
  world_tracker_world_anchor_pose_raw(o: zappar_world_tracker_t): Float32Array;
214
219
  world_tracker_world_anchor_pose_camera_relative(o: zappar_world_tracker_t, mirror: boolean): Float32Array;
@@ -222,6 +227,8 @@ export interface zappar {
222
227
  world_tracker_tracks_data_enabled_set(o: zappar_world_tracker_t, tracks_data_enabled: boolean): void;
223
228
  world_tracker_tracks_data_size(o: zappar_world_tracker_t): number;
224
229
  world_tracker_tracks_data(o: zappar_world_tracker_t): Float32Array;
230
+ world_tracker_tracks_type_data_size(o: zappar_world_tracker_t): number;
231
+ world_tracker_tracks_type_data(o: zappar_world_tracker_t): Uint8Array;
225
232
  world_tracker_projections_data_enabled(o: zappar_world_tracker_t): boolean;
226
233
  world_tracker_projections_data_enabled_set(o: zappar_world_tracker_t, projections_data_enabled: boolean): void;
227
234
  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 = 300.0 * dataWidth / 320.0;
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;
@@ -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.14";
1
+ export declare const VERSION = "3.0.1-alpha.16";
package/lib/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = "3.0.1-alpha.14";
1
+ export const VERSION = "3.0.1-alpha.16";
@@ -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 = 300.0 * dataWidth / 320.0;
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;