@zappar/zappar-cv 3.0.1-alpha.7 → 3.0.1-beta.0

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 (55) hide show
  1. package/README.md +2 -2
  2. package/lib/additional.d.ts +3 -1
  3. package/lib/deserializer.d.ts +5 -1
  4. package/lib/deserializer.js +12 -0
  5. package/lib/direct.js +1 -1
  6. package/lib/drawaxis.d.ts +2 -0
  7. package/lib/drawaxis.js +137 -0
  8. package/lib/drawgrid.js +5 -2
  9. package/lib/drawpoints.d.ts +1 -0
  10. package/lib/drawpoints.js +2 -2
  11. package/lib/drawpointswithtype.d.ts +13 -0
  12. package/lib/drawpointswithtype.js +190 -0
  13. package/lib/drawpolygon.d.ts +5 -0
  14. package/lib/drawpolygon.js +94 -0
  15. package/lib/gen/zappar-bridge.d.ts +44 -11
  16. package/lib/gen/zappar-bridge.js +3 -0
  17. package/lib/gen/zappar-client.d.ts +1 -0
  18. package/lib/gen/zappar-client.js +347 -47
  19. package/lib/gen/zappar-cwrap.js +251 -41
  20. package/lib/gen/zappar-native.d.ts +56 -13
  21. package/lib/gen/zappar-native.js +23 -1
  22. package/lib/gen/zappar-server.d.ts +3 -0
  23. package/lib/gen/zappar-server.js +166 -21
  24. package/lib/gen/zappar.d.ts +51 -13
  25. package/lib/gen/zappar.js +3 -0
  26. package/lib/html-element-source.d.ts +4 -0
  27. package/lib/html-element-source.js +30 -2
  28. package/lib/index.d.ts +1 -1
  29. package/lib/index.js +1 -1
  30. package/lib/mstp-camera-source.js +2 -1
  31. package/lib/native.js +59 -4
  32. package/lib/permission.js +35 -9
  33. package/lib/pipeline.d.ts +1 -1
  34. package/lib/pipeline.js +3 -2
  35. package/lib/sequencesource.js +1 -1
  36. package/lib/serializer.d.ts +5 -1
  37. package/lib/serializer.js +4 -0
  38. package/lib/tr.js +1 -1
  39. package/lib/version.d.ts +1 -1
  40. package/lib/version.js +1 -1
  41. package/lib/worker-client.js +4 -1
  42. package/lib/worker-imagebitmap.js +1 -1
  43. package/lib/worker-server.d.ts +1 -1
  44. package/lib/worker-server.js +5 -5
  45. package/lib/worker.js +1 -1
  46. package/lib/workerinterface.d.ts +1 -0
  47. package/lib/zappar-cv.js +1 -180
  48. package/lib/zappar-cv.wasm +0 -0
  49. package/package.json +1 -1
  50. package/umd/751.zappar-cv.js +1 -1
  51. package/umd/867.zappar-cv.js +1 -1
  52. package/umd/c8e05439176ea756192a.wasm +0 -0
  53. package/umd/zappar-cv.js +1 -1
  54. package/umd/zappar-cv.worker.js +1 -1
  55. package/umd/7e63bec626d6ccda2134.wasm +0 -0
@@ -28,6 +28,8 @@ export class zappar_server {
28
28
  this._zapcode_tracker_by_instance = new Map();
29
29
  this._pipeline_id_by_world_tracker_id = new Map();
30
30
  this._world_tracker_by_instance = new Map();
31
+ this._pipeline_id_by_custom_anchor_id = new Map();
32
+ this._custom_anchor_by_instance = new Map();
31
33
  }
32
34
  processBuffer(b) {
33
35
  this._deserializer.setData(b);
@@ -73,7 +75,7 @@ export class zappar_server {
73
75
  let obj = this._pipeline_by_instance.get(clientId);
74
76
  if (obj === undefined)
75
77
  return;
76
- this._impl.pipeline_camera_frame_submit(obj, msg.dataWithLength(), msg.int(), msg.int(), msg.int(), msg.matrix4x4(), msg.cameraModel(), msg.bool());
78
+ this._impl.pipeline_camera_frame_submit(obj, msg.dataWithLength(), msg.int(), msg.int(), msg.int(), msg.matrix4x4(), msg.cameraModel(), msg.bool(), msg.float());
77
79
  break;
78
80
  }
79
81
  case 10: {
@@ -417,7 +419,7 @@ export class zappar_server {
417
419
  let obj = this._world_tracker_by_instance.get(clientId);
418
420
  if (obj === undefined)
419
421
  return;
420
- this._impl.world_tracker_reset(obj);
422
+ this._impl.world_tracker_horizontal_plane_detection_enabled_set(obj, msg.bool());
421
423
  break;
422
424
  }
423
425
  case 49: {
@@ -425,7 +427,76 @@ export class zappar_server {
425
427
  let obj = this._world_tracker_by_instance.get(clientId);
426
428
  if (obj === undefined)
427
429
  return;
428
- this._impl.world_tracker_debug_enabled_set(obj, msg.bool());
430
+ this._impl.world_tracker_vertical_plane_detection_enabled_set(obj, msg.bool());
431
+ break;
432
+ }
433
+ case 50: {
434
+ let clientId = msg.type();
435
+ let obj = this._world_tracker_by_instance.get(clientId);
436
+ if (obj === undefined)
437
+ return;
438
+ this._impl.world_tracker_reset(obj);
439
+ break;
440
+ }
441
+ case 51: {
442
+ let clientId = msg.type();
443
+ let obj = this._world_tracker_by_instance.get(clientId);
444
+ if (obj === undefined)
445
+ return;
446
+ this._impl.world_tracker_tracks_data_enabled_set(obj, msg.bool());
447
+ break;
448
+ }
449
+ case 52: {
450
+ let clientId = msg.type();
451
+ let obj = this._world_tracker_by_instance.get(clientId);
452
+ if (obj === undefined)
453
+ return;
454
+ this._impl.world_tracker_projections_data_enabled_set(obj, msg.bool());
455
+ break;
456
+ }
457
+ case 53: {
458
+ let clientId = msg.type();
459
+ let arg_pipeline_id = msg.type();
460
+ let arg_pipeline = this._pipeline_by_instance.get(arg_pipeline_id);
461
+ let arg_worldtracker_id = msg.type();
462
+ let arg_worldtracker = this._world_tracker_by_instance.get(arg_worldtracker_id);
463
+ let arg_id = msg.string();
464
+ let handle = this._impl.custom_anchor_create(arg_pipeline, arg_worldtracker, arg_id);
465
+ this._custom_anchor_by_instance.set(clientId, handle);
466
+ this._pipeline_id_by_custom_anchor_id.set(clientId, arg_pipeline_id);
467
+ break;
468
+ }
469
+ case 54: {
470
+ let clientId = msg.type();
471
+ let obj = this._custom_anchor_by_instance.get(clientId);
472
+ if (obj === undefined)
473
+ return;
474
+ this._impl.custom_anchor_destroy(obj);
475
+ this._custom_anchor_by_instance.delete(clientId);
476
+ break;
477
+ }
478
+ case 55: {
479
+ let clientId = msg.type();
480
+ let obj = this._custom_anchor_by_instance.get(clientId);
481
+ if (obj === undefined)
482
+ return;
483
+ this._impl.custom_anchor_enabled_set(obj, msg.bool());
484
+ break;
485
+ }
486
+ case 56: {
487
+ let clientId = msg.type();
488
+ let obj = this._custom_anchor_by_instance.get(clientId);
489
+ if (obj === undefined)
490
+ return;
491
+ this._impl.custom_anchor_pose_set_from_camera_offset_raw(obj, msg.float(), msg.float(), msg.float(), msg.transformOrientation());
492
+ break;
493
+ }
494
+ case 57: {
495
+ let clientId = msg.type();
496
+ let obj = this._custom_anchor_by_instance.get(clientId);
497
+ if (obj === undefined)
498
+ return;
499
+ this._impl.custom_anchor_pose_set_from_anchor_offset(obj, msg.string(), msg.float(), msg.float(), msg.float(), msg.transformOrientation());
429
500
  break;
430
501
  }
431
502
  }
@@ -641,52 +712,126 @@ export class zappar_server {
641
712
  let serializer = this.serializersByPipelineId.get(pipeline);
642
713
  if (!serializer)
643
714
  continue;
644
- serializer.sendMessage(31, msg => {
715
+ serializer.sendMessage(40, msg => {
645
716
  msg.type(k);
646
717
  msg.int(this._impl.world_tracker_quality(v));
647
718
  });
648
719
  serializer.sendMessage(25, msg => {
649
720
  msg.type(k);
650
- msg.int(this._impl.world_tracker_plane_count(v));
721
+ msg.int(this._impl.world_tracker_plane_anchor_count(v));
651
722
  });
652
- for (let i = 0; i < this._impl.world_tracker_plane_count(v); i++) {
723
+ for (let i = 0; i < this._impl.world_tracker_plane_anchor_count(v); i++) {
724
+ serializer.sendMessage(33, msg => {
725
+ msg.type(k);
726
+ msg.int(i);
727
+ msg.string(this._impl.world_tracker_plane_anchor_id(v, i));
728
+ });
729
+ }
730
+ for (let i = 0; i < this._impl.world_tracker_plane_anchor_count(v); i++) {
653
731
  serializer.sendMessage(26, msg => {
654
732
  msg.type(k);
655
733
  msg.int(i);
656
- msg.matrix4x4(this._impl.world_tracker_plane_pose_raw(v, i));
734
+ msg.matrix4x4(this._impl.world_tracker_plane_anchor_pose_raw(v, i));
735
+ });
736
+ }
737
+ for (let i = 0; i < this._impl.world_tracker_plane_anchor_count(v); i++) {
738
+ serializer.sendMessage(28, msg => {
739
+ msg.type(k);
740
+ msg.int(i);
741
+ msg.anchorStatus(this._impl.world_tracker_plane_anchor_status(v, i));
742
+ });
743
+ }
744
+ for (let i = 0; i < this._impl.world_tracker_plane_anchor_count(v); i++) {
745
+ serializer.sendMessage(29, msg => {
746
+ msg.type(k);
747
+ msg.int(i);
748
+ msg.int(this._impl.world_tracker_plane_anchor_polygon_data_size(v, i));
749
+ });
750
+ }
751
+ for (let i = 0; i < this._impl.world_tracker_plane_anchor_count(v); i++) {
752
+ serializer.sendMessage(30, msg => {
753
+ msg.type(k);
754
+ msg.int(i);
755
+ msg.floatArray(this._impl.world_tracker_plane_anchor_polygon_data(v, i));
756
+ });
757
+ }
758
+ for (let i = 0; i < this._impl.world_tracker_plane_anchor_count(v); i++) {
759
+ serializer.sendMessage(31, msg => {
760
+ msg.type(k);
761
+ msg.int(i);
762
+ msg.int(this._impl.world_tracker_plane_anchor_polygon_version(v, i));
763
+ });
764
+ }
765
+ for (let i = 0; i < this._impl.world_tracker_plane_anchor_count(v); i++) {
766
+ serializer.sendMessage(32, msg => {
767
+ msg.type(k);
768
+ msg.int(i);
769
+ msg.planeOrientation(this._impl.world_tracker_plane_anchor_orientation(v, i));
657
770
  });
658
771
  }
659
- serializer.sendMessage(27, msg => {
772
+ serializer.sendMessage(36, msg => {
660
773
  msg.type(k);
661
- msg.bool(this._impl.world_tracker_world_anchor_valid(v));
774
+ msg.anchorStatus(this._impl.world_tracker_world_anchor_status(v));
662
775
  });
663
- serializer.sendMessage(28, msg => {
776
+ serializer.sendMessage(35, msg => {
777
+ msg.type(k);
778
+ msg.string(this._impl.world_tracker_world_anchor_id(v));
779
+ });
780
+ serializer.sendMessage(34, msg => {
664
781
  msg.type(k);
665
782
  msg.matrix4x4(this._impl.world_tracker_world_anchor_pose_raw(v));
666
783
  });
667
- serializer.sendMessage(27, msg => {
784
+ serializer.sendMessage(38, msg => {
785
+ msg.type(k);
786
+ msg.string(this._impl.world_tracker_ground_anchor_id(v));
787
+ });
788
+ serializer.sendMessage(39, msg => {
668
789
  msg.type(k);
669
- msg.bool(this._impl.world_tracker_ground_anchor_valid(v));
790
+ msg.anchorStatus(this._impl.world_tracker_ground_anchor_status(v));
670
791
  });
671
- serializer.sendMessage(30, msg => {
792
+ serializer.sendMessage(37, msg => {
672
793
  msg.type(k);
673
794
  msg.matrix4x4(this._impl.world_tracker_ground_anchor_pose_raw(v));
674
795
  });
675
- serializer.sendMessage(33, msg => {
796
+ serializer.sendMessage(43, msg => {
676
797
  msg.type(k);
677
- msg.int(this._impl.world_tracker_debug_tracks_data_size(v));
798
+ msg.int(this._impl.world_tracker_tracks_data_size(v));
678
799
  });
679
- serializer.sendMessage(32, msg => {
800
+ serializer.sendMessage(42, msg => {
680
801
  msg.type(k);
681
- msg.floatArray(this._impl.world_tracker_debug_tracks_data(v));
802
+ msg.floatArray(this._impl.world_tracker_tracks_data(v));
682
803
  });
683
- serializer.sendMessage(35, msg => {
804
+ serializer.sendMessage(45, msg => {
684
805
  msg.type(k);
685
- msg.int(this._impl.world_tracker_debug_projections_data_size(v));
806
+ msg.int(this._impl.world_tracker_tracks_type_data_size(v));
686
807
  });
687
- serializer.sendMessage(34, msg => {
808
+ serializer.sendMessage(44, msg => {
809
+ msg.type(k);
810
+ msg.ucharArray(this._impl.world_tracker_tracks_type_data(v));
811
+ });
812
+ serializer.sendMessage(48, msg => {
813
+ msg.type(k);
814
+ msg.int(this._impl.world_tracker_projections_data_size(v));
815
+ });
816
+ serializer.sendMessage(47, msg => {
817
+ msg.type(k);
818
+ msg.floatArray(this._impl.world_tracker_projections_data(v));
819
+ });
820
+ }
821
+ for (let [k, v] of this._custom_anchor_by_instance) {
822
+ let pipeline = this._pipeline_id_by_custom_anchor_id.get(k);
823
+ if (!pipeline)
824
+ continue;
825
+ let serializer = this.serializersByPipelineId.get(pipeline);
826
+ if (!serializer)
827
+ continue;
828
+ serializer.sendMessage(50, msg => {
829
+ msg.type(k);
830
+ msg.anchorStatus(this._impl.custom_anchor_status(v));
831
+ });
832
+ serializer.sendMessage(49, msg => {
688
833
  msg.type(k);
689
- msg.floatArray(this._impl.world_tracker_debug_projections_data(v));
834
+ msg.matrix4x4(this._impl.custom_anchor_pose_raw(v));
690
835
  });
691
836
  }
692
837
  }
@@ -5,11 +5,17 @@ export { face_landmark_name_t } from "./zappar-native";
5
5
  export { frame_pixel_format_t } from "./zappar-native";
6
6
  import { instant_world_tracker_transform_orientation_t } from "./zappar-native";
7
7
  export { instant_world_tracker_transform_orientation_t } from "./zappar-native";
8
+ import { transform_orientation_t } from "./zappar-native";
9
+ export { transform_orientation_t } from "./zappar-native";
10
+ import { plane_orientation_t } from "./zappar-native";
11
+ export { plane_orientation_t } from "./zappar-native";
8
12
  import { log_level_t } from "./zappar-native";
9
13
  export { log_level_t } from "./zappar-native";
10
14
  import { image_target_type_t } from "./zappar-native";
11
15
  export { image_target_type_t } from "./zappar-native";
12
16
  export { world_tracker_quality_t } from "./zappar-native";
17
+ import { anchor_status_t } from "./zappar-native";
18
+ export { anchor_status_t } from "./zappar-native";
13
19
  import { camera_profile_t } from "./zappar-native";
14
20
  export { camera_profile_t } from "./zappar-native";
15
21
  export declare type zappar_pipeline_t = number & {
@@ -45,6 +51,9 @@ export declare type zappar_zapcode_tracker_t = number & {
45
51
  export declare type zappar_world_tracker_t = number & {
46
52
  _: 'zappar_world_tracker_t';
47
53
  };
54
+ export declare type zappar_custom_anchor_t = number & {
55
+ _: 'zappar_custom_anchor_t';
56
+ };
48
57
  export interface zappar {
49
58
  loaded(): boolean;
50
59
  camera_default_device_id(userFacing: boolean): string;
@@ -82,7 +91,7 @@ export interface zappar {
82
91
  pipeline_camera_pose_with_attitude(o: zappar_pipeline_t, mirror: boolean): Float32Array;
83
92
  pipeline_camera_pose_with_origin(o: zappar_pipeline_t, pose: Float32Array): Float32Array;
84
93
  pipeline_camera_frame_user_data(o: zappar_pipeline_t): number;
85
- 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): void;
94
+ 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, timestampSeconds: number): void;
86
95
  pipeline_camera_frame_camera_attitude(o: zappar_pipeline_t): Float32Array;
87
96
  pipeline_camera_frame_device_attitude(o: zappar_pipeline_t): Float32Array;
88
97
  pipeline_camera_frame_user_facing(o: zappar_pipeline_t): boolean;
@@ -205,23 +214,52 @@ export interface zappar {
205
214
  world_tracker_enabled(o: zappar_world_tracker_t): boolean;
206
215
  world_tracker_enabled_set(o: zappar_world_tracker_t, enabled: boolean): void;
207
216
  world_tracker_quality(o: zappar_world_tracker_t): number;
208
- world_tracker_plane_count(o: zappar_world_tracker_t): number;
209
- world_tracker_plane_pose_raw(o: zappar_world_tracker_t, indx: number): Float32Array;
210
- world_tracker_plane_pose_camera_relative(o: zappar_world_tracker_t, indx: number, mirror: boolean): Float32Array;
211
- world_tracker_plane_pose(o: zappar_world_tracker_t, indx: number, camera_pose: Float32Array, mirror: boolean): Float32Array;
212
- world_tracker_world_anchor_valid(o: zappar_world_tracker_t): boolean;
217
+ world_tracker_horizontal_plane_detection_enabled(o: zappar_world_tracker_t): boolean;
218
+ world_tracker_horizontal_plane_detection_enabled_set(o: zappar_world_tracker_t, horizontal_plane_detection_enabled: boolean): void;
219
+ world_tracker_vertical_plane_detection_enabled(o: zappar_world_tracker_t): boolean;
220
+ world_tracker_vertical_plane_detection_enabled_set(o: zappar_world_tracker_t, vertical_plane_detection_enabled: boolean): void;
221
+ world_tracker_vertical_plane_detection_supported(o: zappar_world_tracker_t): boolean;
222
+ world_tracker_plane_anchor_count(o: zappar_world_tracker_t): number;
223
+ world_tracker_plane_anchor_id(o: zappar_world_tracker_t, indx: number): string;
224
+ world_tracker_plane_anchor_pose_raw(o: zappar_world_tracker_t, indx: number): Float32Array;
225
+ world_tracker_plane_anchor_status(o: zappar_world_tracker_t, indx: number): anchor_status_t;
226
+ world_tracker_plane_anchor_pose_camera_relative(o: zappar_world_tracker_t, indx: number, mirror: boolean): Float32Array;
227
+ world_tracker_plane_anchor_pose(o: zappar_world_tracker_t, indx: number, camera_pose: Float32Array, mirror: boolean): Float32Array;
228
+ world_tracker_plane_anchor_polygon_data_size(o: zappar_world_tracker_t, indx: number): number;
229
+ world_tracker_plane_anchor_polygon_data(o: zappar_world_tracker_t, indx: number): Float32Array;
230
+ world_tracker_plane_anchor_polygon_version(o: zappar_world_tracker_t, indx: number): number;
231
+ world_tracker_plane_anchor_orientation(o: zappar_world_tracker_t, indx: number): plane_orientation_t;
232
+ world_tracker_world_anchor_status(o: zappar_world_tracker_t): anchor_status_t;
233
+ world_tracker_world_anchor_id(o: zappar_world_tracker_t): string;
213
234
  world_tracker_world_anchor_pose_raw(o: zappar_world_tracker_t): Float32Array;
214
235
  world_tracker_world_anchor_pose_camera_relative(o: zappar_world_tracker_t, mirror: boolean): Float32Array;
215
236
  world_tracker_world_anchor_pose(o: zappar_world_tracker_t, camera_pose: Float32Array, mirror: boolean): Float32Array;
216
- world_tracker_ground_anchor_valid(o: zappar_world_tracker_t): boolean;
237
+ world_tracker_ground_anchor_id(o: zappar_world_tracker_t): string;
238
+ world_tracker_ground_anchor_status(o: zappar_world_tracker_t): anchor_status_t;
217
239
  world_tracker_ground_anchor_pose_raw(o: zappar_world_tracker_t): Float32Array;
218
240
  world_tracker_ground_anchor_pose_camera_relative(o: zappar_world_tracker_t, mirror: boolean): Float32Array;
219
241
  world_tracker_ground_anchor_pose(o: zappar_world_tracker_t, camera_pose: Float32Array, mirror: boolean): Float32Array;
220
242
  world_tracker_reset(o: zappar_world_tracker_t): void;
221
- world_tracker_debug_enabled(o: zappar_world_tracker_t): boolean;
222
- world_tracker_debug_enabled_set(o: zappar_world_tracker_t, debug_enabled: boolean): void;
223
- world_tracker_debug_tracks_data_size(o: zappar_world_tracker_t): number;
224
- world_tracker_debug_tracks_data(o: zappar_world_tracker_t): Float32Array;
225
- world_tracker_debug_projections_data_size(o: zappar_world_tracker_t): number;
226
- world_tracker_debug_projections_data(o: zappar_world_tracker_t): Float32Array;
243
+ world_tracker_tracks_data_enabled(o: zappar_world_tracker_t): boolean;
244
+ world_tracker_tracks_data_enabled_set(o: zappar_world_tracker_t, tracks_data_enabled: boolean): void;
245
+ world_tracker_tracks_data_size(o: zappar_world_tracker_t): number;
246
+ world_tracker_tracks_data(o: zappar_world_tracker_t): Float32Array;
247
+ world_tracker_tracks_type_data_size(o: zappar_world_tracker_t): number;
248
+ world_tracker_tracks_type_data(o: zappar_world_tracker_t): Uint8Array;
249
+ world_tracker_projections_data_enabled(o: zappar_world_tracker_t): boolean;
250
+ world_tracker_projections_data_enabled_set(o: zappar_world_tracker_t, projections_data_enabled: boolean): void;
251
+ world_tracker_projections_data_size(o: zappar_world_tracker_t): number;
252
+ world_tracker_projections_data(o: zappar_world_tracker_t): Float32Array;
253
+ custom_anchor_create(pipeline: zappar_pipeline_t, worldtracker: zappar_world_tracker_t, id: string): zappar_custom_anchor_t;
254
+ custom_anchor_destroy(o: zappar_custom_anchor_t): void;
255
+ custom_anchor_id(o: zappar_custom_anchor_t): string;
256
+ custom_anchor_status(o: zappar_custom_anchor_t): anchor_status_t;
257
+ custom_anchor_enabled_set(o: zappar_custom_anchor_t, enabled: boolean): void;
258
+ custom_anchor_enabled(o: zappar_custom_anchor_t): boolean;
259
+ custom_anchor_pose_raw(o: zappar_custom_anchor_t): Float32Array;
260
+ custom_anchor_pose_camera_relative(o: zappar_custom_anchor_t, mirror: boolean): Float32Array;
261
+ custom_anchor_pose(o: zappar_custom_anchor_t, camera_pose: Float32Array, mirror: boolean): Float32Array;
262
+ custom_anchor_pose_set_from_camera_offset_raw(o: zappar_custom_anchor_t, x: number, y: number, z: number, orientation: transform_orientation_t): void;
263
+ custom_anchor_pose_set_from_camera_offset(o: zappar_custom_anchor_t, x: number, y: number, z: number, orientation: transform_orientation_t): void;
264
+ custom_anchor_pose_set_from_anchor_offset(o: zappar_custom_anchor_t, anchor_id: string, x: number, y: number, z: number, orientation: transform_orientation_t): void;
227
265
  }
package/lib/gen/zappar.js CHANGED
@@ -2,7 +2,10 @@ export { barcode_format_t } from "./zappar-native";
2
2
  export { face_landmark_name_t } from "./zappar-native";
3
3
  export { frame_pixel_format_t } from "./zappar-native";
4
4
  export { instant_world_tracker_transform_orientation_t } from "./zappar-native";
5
+ export { transform_orientation_t } from "./zappar-native";
6
+ export { plane_orientation_t } from "./zappar-native";
5
7
  export { log_level_t } from "./zappar-native";
6
8
  export { image_target_type_t } from "./zappar-native";
7
9
  export { world_tracker_quality_t } from "./zappar-native";
10
+ export { anchor_status_t } from "./zappar-native";
8
11
  export { camera_profile_t } from "./zappar-native";
@@ -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,9 @@ 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 _frameTime;
29
+ private _requestVideoFrameCallback;
26
30
  private _processFrame;
27
31
  uploadGL(): void;
28
32
  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) {
@@ -76,6 +78,7 @@ export class HTMLElementSource extends Source {
76
78
  }
77
79
  }
78
80
  getFrame(currentlyProcessing) {
81
+ var _a;
79
82
  let pipeline = Pipeline.get(this._pipeline);
80
83
  if (!pipeline)
81
84
  return;
@@ -90,7 +93,7 @@ export class HTMLElementSource extends Source {
90
93
  let info = this._processFrame(gl, this._cameraToScreenRotation, currentlyProcessing);
91
94
  if (info) {
92
95
  let token = pipeline.registerToken(info);
93
- pipeline.sendDataToWorker(info.data || new ArrayBuffer(0), token, info.dataWidth, info.dataHeight, info.userFacing, info.cameraToDevice, info.cameraModel);
96
+ pipeline.sendDataToWorker(info.data || new ArrayBuffer(0), token, info.dataWidth, info.dataHeight, info.userFacing, info.cameraToDevice, info.cameraModel, (_a = this._frameTime) !== null && _a !== void 0 ? _a : performance.now());
94
97
  info.data = undefined;
95
98
  }
96
99
  }
@@ -99,6 +102,28 @@ export class HTMLElementSource extends Source {
99
102
  }
100
103
  return;
101
104
  }
105
+ _requestVideoFrameCallback() {
106
+ const video = this._video;
107
+ if (!(video === null || video === void 0 ? void 0 : video.requestVideoFrameCallback))
108
+ return;
109
+ video.requestVideoFrameCallback((time, metadata) => {
110
+ var _a;
111
+ if (typeof metadata === 'object')
112
+ this._frameTime = ((_a = metadata.captureTime) !== null && _a !== void 0 ? _a : -1) / 1000.0;
113
+ if (typeof metadata === 'object' && typeof metadata.presentedFrames === 'number') {
114
+ if (this._lastPresentedFrames === metadata.presentedFrames) {
115
+ console.log('Avoided identical frame');
116
+ this._requestVideoFrameCallback();
117
+ return;
118
+ }
119
+ else {
120
+ this._lastPresentedFrames = metadata.presentedFrames;
121
+ }
122
+ }
123
+ this._waitingForFrame = false;
124
+ });
125
+ this._waitingForFrame = true;
126
+ }
102
127
  _processFrame(gl, rotation, currentlyProcessing) {
103
128
  let pipeline = Pipeline.get(this._pipeline);
104
129
  if (!pipeline)
@@ -106,12 +131,15 @@ export class HTMLElementSource extends Source {
106
131
  if (!this._imageProcessor)
107
132
  this._imageProcessor = new ImageProcessGL(gl);
108
133
  if (this._isUploadFrame) {
134
+ if (this._waitingForFrame)
135
+ return;
109
136
  if (!this._currentVideoTexture) {
110
137
  this._currentVideoTexture = pipeline.getVideoTexture();
111
138
  }
112
139
  if (!this._currentVideoTexture)
113
140
  return undefined;
114
141
  this._imageProcessor.uploadFrame(this._currentVideoTexture, this._video, rotation, this._isUserFacing, this._profile);
142
+ this._requestVideoFrameCallback();
115
143
  this._isUploadFrame = !this._isUploadFrame;
116
144
  return undefined;
117
145
  }
@@ -131,7 +159,7 @@ export class HTMLElementSource extends Source {
131
159
  }
132
160
  let tex = this._currentVideoTexture;
133
161
  this._currentVideoTexture = undefined;
134
- let focalLength = 300.0 * dataWidth / 320.0;
162
+ let focalLength = 240.0 * dataWidth / 320.0;
135
163
  this._cameraModel[0] = focalLength;
136
164
  this._cameraModel[1] = focalLength;
137
165
  this._cameraModel[2] = dataWidth * 0.5;
package/lib/index.d.ts CHANGED
@@ -4,4 +4,4 @@ import { Options } from "./options";
4
4
  export declare type Zappar = zappar & Additional;
5
5
  export declare function initialize(opts?: Options): Zappar;
6
6
  export { CameraFrameData } from './camera-frame-data';
7
- export { zappar_image_tracker_t, zappar_instant_world_tracker_t, zappar_world_tracker_t, zappar_barcode_finder_t, zappar_face_tracker_t, zappar_face_landmark_t, zappar_zapcode_tracker_t, barcode_format_t, face_landmark_name_t, instant_world_tracker_transform_orientation_t, log_level_t, zappar_face_mesh_t, zappar_pipeline_t, zappar_camera_source_t, zappar_sequence_source_t, image_target_type_t, world_tracker_quality_t, camera_profile_t } from "./gen/zappar";
7
+ export { zappar_image_tracker_t, zappar_instant_world_tracker_t, zappar_world_tracker_t, zappar_barcode_finder_t, zappar_face_tracker_t, zappar_face_landmark_t, zappar_zapcode_tracker_t, zappar_custom_anchor_t, barcode_format_t, face_landmark_name_t, instant_world_tracker_transform_orientation_t, log_level_t, zappar_face_mesh_t, zappar_pipeline_t, zappar_camera_source_t, zappar_sequence_source_t, image_target_type_t, world_tracker_quality_t, camera_profile_t, transform_orientation_t, plane_orientation_t, anchor_status_t, } from "./gen/zappar";
package/lib/index.js CHANGED
@@ -4,4 +4,4 @@ export function initialize(opts) {
4
4
  console.log(`Zappar CV v${VERSION}`);
5
5
  return nativeInitialize(opts);
6
6
  }
7
- export { barcode_format_t, face_landmark_name_t, instant_world_tracker_transform_orientation_t, log_level_t, image_target_type_t, world_tracker_quality_t, camera_profile_t } from "./gen/zappar";
7
+ export { barcode_format_t, face_landmark_name_t, instant_world_tracker_transform_orientation_t, log_level_t, image_target_type_t, world_tracker_quality_t, camera_profile_t, transform_orientation_t, plane_orientation_t, anchor_status_t, } from "./gen/zappar";
@@ -234,7 +234,8 @@ export class MSTPCameraSource extends Source {
234
234
  if (videoTracks.length > 0) {
235
235
  this._isUserFacing = videoTracks[0].getSettings().facingMode === "user";
236
236
  let processor = new MediaStreamTrackProcessor({
237
- track: videoTracks[0]
237
+ track: videoTracks[0],
238
+ maxBufferSize: 1
238
239
  });
239
240
  const str = this._currentStream;
240
241
  yield delay(1000);
package/lib/native.js CHANGED
@@ -27,7 +27,10 @@ import { gfx } from "./gfx";
27
27
  import { ImageTracker } from "./imagetracker";
28
28
  import { MSTPCameraSource } from "./mstp-camera-source";
29
29
  import { drawGrid } from "./drawgrid";
30
+ import { getPointsDataMatrix } from "./drawpoints";
31
+ import { drawAxis } from "./drawaxis";
30
32
  let client;
33
+ const pipelineByWorldTracker = new Map();
31
34
  export function initialize(opts) {
32
35
  if (client)
33
36
  return client;
@@ -147,6 +150,7 @@ export function initialize(opts) {
147
150
  }
148
151
  }
149
152
  });
153
+ const customAnchorIDs = new Map();
150
154
  client = Object.assign(Object.assign({}, c.impl), { loaded: () => loaded, camera_default_device_id: userFacing => userFacing ? CameraSource.USER_DEFAULT_DEVICE_ID : CameraSource.DEFAULT_DEVICE_ID, camera_source_create: (p, deviceId) => createCameraSource(p, deviceId), camera_source_destroy: cam => { var _a; return (_a = getCameraSource(cam)) === null || _a === void 0 ? void 0 : _a.destroy(); }, camera_source_pause: cam => { var _a; return (_a = getCameraSource(cam)) === null || _a === void 0 ? void 0 : _a.pause(); }, camera_source_start: cam => { var _a; return (_a = getCameraSource(cam)) === null || _a === void 0 ? void 0 : _a.start(); }, camera_source_profile_set: (cam, p) => { var _a; return (_a = getCameraSource(cam)) === null || _a === void 0 ? void 0 : _a.setProfile(p); }, camera_count: () => 2, camera_id: indx => indx === 0 ? CameraSource.DEFAULT_DEVICE_ID : CameraSource.USER_DEFAULT_DEVICE_ID, camera_name: indx => indx === 0 ? "Rear-facing Camera" : "User-facing Camera", camera_user_facing: indx => indx !== 0, pose_from_raw: (raw_pose, mirror) => {
151
155
  let res = applyScreenCounterRotation(undefined, raw_pose);
152
156
  if (mirror) {
@@ -171,6 +175,8 @@ export function initialize(opts) {
171
175
  drawPlane(gl, projectionMatrix, cameraMatrix, targetMatrix, texture);
172
176
  }, draw_grid: (gl, projectionMatrix, cameraMatrix, targetMatrix) => {
173
177
  drawGrid(gl, projectionMatrix, cameraMatrix, targetMatrix);
178
+ }, draw_axis: (gl, projectionMatrix, cameraMatrix, targetMatrix) => {
179
+ drawAxis(gl, projectionMatrix, cameraMatrix, targetMatrix);
174
180
  }, pipeline_draw_face: (p, projectionMatrix, cameraMatrix, targetMatrix, o) => {
175
181
  var _a;
176
182
  let obj = getFaceMesh(o);
@@ -222,6 +228,44 @@ export function initialize(opts) {
222
228
  let rawVec = vec3.create();
223
229
  vec3.transformMat4(rawVec, [x, y, z], rotationMat);
224
230
  c.impl.instant_world_tracker_anchor_pose_set_from_camera_offset_raw(o, rawVec[0], rawVec[1], rawVec[2], orientation);
231
+ }, custom_anchor_pose_camera_relative: (o, mirror) => {
232
+ let res = applyScreenCounterRotation(undefined, c.impl.custom_anchor_pose_raw(o));
233
+ if (mirror) {
234
+ let scale = mat4.create();
235
+ mat4.fromScaling(scale, [-1, 1, 1]);
236
+ mat4.multiply(res, scale, res);
237
+ mat4.multiply(res, res, scale);
238
+ }
239
+ return res;
240
+ }, custom_anchor_pose: (o, cameraPose, mirror) => {
241
+ let res = applyScreenCounterRotation(undefined, c.impl.custom_anchor_pose_raw(o));
242
+ if (mirror) {
243
+ let scale = mat4.create();
244
+ mat4.fromScaling(scale, [-1, 1, 1]);
245
+ mat4.multiply(res, scale, res);
246
+ mat4.multiply(res, res, scale);
247
+ }
248
+ mat4.multiply(res, cameraPose, res);
249
+ return res;
250
+ }, custom_anchor_create: (p, wt, id) => {
251
+ const ret = c.impl.custom_anchor_create(p, wt, id);
252
+ customAnchorIDs.set(ret, id);
253
+ return ret;
254
+ }, custom_anchor_id: (o) => {
255
+ let id = customAnchorIDs.get(o);
256
+ if (!id) {
257
+ zcwarn("attempting to call custom_anchor_id on a destroyed zappar_custom_anchor_t");
258
+ return "";
259
+ }
260
+ return id;
261
+ }, custom_anchor_pose_set_from_camera_offset: (o, x, y, z, orientation) => {
262
+ let userFacing = false;
263
+ let rotation = cameraRotationForScreenOrientation(userFacing) * Math.PI / 180.0;
264
+ let rotationMat = mat4.create();
265
+ mat4.fromRotation(rotationMat, -rotation, [0, 0, 1]);
266
+ let rawVec = vec3.create();
267
+ vec3.transformMat4(rawVec, [x, y, z], rotationMat);
268
+ c.impl.custom_anchor_pose_set_from_camera_offset_raw(o, rawVec[0], rawVec[1], rawVec[2], orientation);
225
269
  }, image_tracker_create: pipeline => ImageTracker.create(pipeline, c.impl), image_tracker_destroy: t => { var _a; return (_a = ImageTracker.get(t)) === null || _a === void 0 ? void 0 : _a.destroy(); }, image_tracker_target_type: (t, i) => {
226
270
  let obj = ImageTracker.get(t);
227
271
  if (!obj) {
@@ -543,8 +587,17 @@ export function initialize(opts) {
543
587
  return mat4.create();
544
588
  }
545
589
  return obj.anchor_pose;
546
- }, world_tracker_plane_pose_camera_relative: (o, indx, mirror) => {
547
- let res = applyScreenCounterRotation(undefined, c.impl.world_tracker_plane_pose_raw(o, indx));
590
+ }, world_tracker_create: (pipeline) => {
591
+ const ret = c.impl.world_tracker_create(pipeline);
592
+ pipelineByWorldTracker.set(ret, pipeline);
593
+ return ret;
594
+ }, world_tracker_points_data_matrix: (wt, screenWidth, screenHeight, mirror) => {
595
+ const pipeline = pipelineByWorldTracker.get(wt);
596
+ if (pipeline === undefined || !client)
597
+ return mat4.create();
598
+ return getPointsDataMatrix(client.pipeline_camera_frame_data_width(pipeline), client.pipeline_camera_frame_data_height(pipeline), screenWidth, screenHeight, mirror);
599
+ }, world_tracker_plane_anchor_pose_camera_relative: (o, indx, mirror) => {
600
+ let res = applyScreenCounterRotation(undefined, c.impl.world_tracker_plane_anchor_pose_raw(o, indx));
548
601
  if (mirror) {
549
602
  let scale = mat4.create();
550
603
  mat4.fromScaling(scale, [-1, 1, 1]);
@@ -552,8 +605,8 @@ export function initialize(opts) {
552
605
  mat4.multiply(res, res, scale);
553
606
  }
554
607
  return res;
555
- }, world_tracker_plane_pose: (o, indx, cameraPose, mirror) => {
556
- let res = applyScreenCounterRotation(undefined, c.impl.world_tracker_plane_pose_raw(o, indx));
608
+ }, world_tracker_plane_anchor_pose: (o, indx, cameraPose, mirror) => {
609
+ let res = applyScreenCounterRotation(undefined, c.impl.world_tracker_plane_anchor_pose_raw(o, indx));
557
610
  if (mirror) {
558
611
  let scale = mat4.create();
559
612
  mat4.fromScaling(scale, [-1, 1, 1]);
@@ -600,6 +653,8 @@ export function initialize(opts) {
600
653
  mat4.multiply(res, res, scale);
601
654
  }
602
655
  return res;
656
+ }, world_tracker_vertical_plane_detection_supported: (o) => {
657
+ return false;
603
658
  }, html_element_source_create: (pipeline, elm) => HTMLElementSource.createVideoElementSource(pipeline, elm), html_element_source_start: o => { var _a; return (_a = HTMLElementSource.getVideoElementSource(o)) === null || _a === void 0 ? void 0 : _a.start(); }, html_element_source_pause: o => { var _a; return (_a = HTMLElementSource.getVideoElementSource(o)) === null || _a === void 0 ? void 0 : _a.pause(); }, html_element_source_destroy: o => { var _a; return (_a = HTMLElementSource.getVideoElementSource(o)) === null || _a === void 0 ? void 0 : _a.destroy(); }, sequence_source_create: p => SequenceSource.create(p), sequence_source_load_from_memory: (o, data) => { var _a; return (_a = SequenceSource.get(o)) === null || _a === void 0 ? void 0 : _a.loadFromMemory(data); }, sequence_source_pause: o => { var _a; return (_a = SequenceSource.get(o)) === null || _a === void 0 ? void 0 : _a.pause(); }, sequence_source_start: o => { var _a; return (_a = SequenceSource.get(o)) === null || _a === void 0 ? void 0 : _a.start(); }, sequence_source_max_playback_fps_set: (o, fps) => { var _a; return (_a = SequenceSource.get(o)) === null || _a === void 0 ? void 0 : _a.maxPlaybackFpsSet(fps); }, sequence_source_time_set: (o, t) => { var _a; return (_a = SequenceSource.get(o)) === null || _a === void 0 ? void 0 : _a.setTime(t); }, sequence_source_destroy: o => { var _a; return (_a = SequenceSource.get(o)) === null || _a === void 0 ? void 0 : _a.destroy(); }, permission_granted_all: permissionGrantedAll, permission_granted_camera: permissionGrantedCamera, permission_granted_motion: permissionGrantedMotion, permission_denied_any: permissionDeniedAny, permission_denied_camera: permissionDeniedCamera, permission_denied_motion: permissionDeniedMotion, permission_request_motion: permissionRequestMotion, permission_request_camera: permissionRequestCamera, permission_request_all: permissionRequestAll, permission_request_ui: permissionRequestUI, permission_request_ui_promise: permissionRequestUI, permission_denied_ui: permissionDeniedUI, browser_incompatible: compatibility.incompatible, browser_incompatible_ui: compatibility.incompatible_ui, log_level_set: l => {
604
659
  setLogLevel(l);
605
660
  c.impl.log_level_set(l);