@zappar/zappar-cv 3.0.1-alpha.15 → 3.0.1-alpha.17

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 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.0.1-alpha.15/zappar-cv.js"></script>
21
+ <script src="https://libs.zappar.com/zappar-cv/3.0.1-alpha.17/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.0.1-alpha.15/zappar-cv.zip](https://libs.zappar.com/zappar-cv/3.0.1-alpha.15/zappar-cv.zip)
25
+ [https://libs.zappar.com/zappar-cv/3.0.1-alpha.17/zappar-cv.zip](https://libs.zappar.com/zappar-cv/3.0.1-alpha.17/zappar-cv.zip)
@@ -15,6 +15,7 @@ export interface Additional {
15
15
  pipeline_camera_frame_data_height(pipeline: zappar_pipeline_t): number;
16
16
  draw_plane(gl: WebGLRenderingContext, projectionMatrix: Float32Array, cameraMatrix: Float32Array, targetMatrix: Float32Array, texture: string): void;
17
17
  draw_grid(gl: WebGLRenderingContext, projectionMatrix: Float32Array, cameraMatrix: Float32Array, targetMatrix: Float32Array): void;
18
+ draw_axis(gl: WebGLRenderingContext, projectionMatrix: Float32Array, cameraMatrix: Float32Array, targetMatrix: Float32Array): void;
18
19
  image_tracker_target_image(o: zappar_image_tracker_t, indx: number): HTMLImageElement | undefined;
19
20
  face_mesh_load_default(o: zappar_face_mesh_t): Promise<void>;
20
21
  face_mesh_load_default_face(o: zappar_face_mesh_t, fillMouth: boolean, fillEyeL: boolean, fillEyeR: boolean): Promise<void>;
@@ -1,4 +1,4 @@
1
- import { barcode_format_t, face_landmark_name_t, instant_world_tracker_transform_orientation_t, log_level_t } from "./gen/zappar-native";
1
+ import { barcode_format_t, face_landmark_name_t, instant_world_tracker_transform_orientation_t, transform_orientation_t, log_level_t, plane_orientation_t, anchor_status_t } from "./gen/zappar-native";
2
2
  interface Message {
3
3
  int: () => number;
4
4
  float: () => number;
@@ -17,6 +17,9 @@ interface Message {
17
17
  barcodeFormat: () => barcode_format_t;
18
18
  faceLandmarkName: () => face_landmark_name_t;
19
19
  instantTrackerTransformOrientation: () => instant_world_tracker_transform_orientation_t;
20
+ transformOrientation: () => transform_orientation_t;
21
+ planeOrientation: () => plane_orientation_t;
22
+ anchorStatus: () => anchor_status_t;
20
23
  logLevel: () => log_level_t;
21
24
  }
22
25
  export declare class MessageDeserializer {
@@ -94,6 +94,9 @@ export class MessageDeserializer {
94
94
  barcodeFormat: () => this._i32View[this._startOffset++],
95
95
  faceLandmarkName: () => this._i32View[this._startOffset++],
96
96
  instantTrackerTransformOrientation: () => this._i32View[this._startOffset++],
97
+ transformOrientation: () => this._i32View[this._startOffset++],
98
+ planeOrientation: () => this._i32View[this._startOffset++],
99
+ anchorStatus: () => this._i32View[this._startOffset++],
97
100
  logLevel: () => this._i32View[this._startOffset++],
98
101
  };
99
102
  }
package/lib/drawgrid.js CHANGED
@@ -100,8 +100,8 @@ uniform sampler2D skinSampler;
100
100
 
101
101
  void main()
102
102
  {
103
- vec2 pixels = 100.0 * vTextureCoord + 0.5;
104
- if ((int(mod(pixels.x, 10.0)) == 0) || (int(mod(pixels.y, 10.0)) == 0)) {
103
+ vec2 pixels = 500.0 * vTextureCoord + 0.5;
104
+ if ((int(mod(pixels.x, 50.0)) == 0) || (int(mod(pixels.y, 50.0)) == 0)) {
105
105
  gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
106
106
  } else {
107
107
  discard;
@@ -0,0 +1,5 @@
1
+ export declare class PolygonDraw {
2
+ private _vbo;
3
+ private _generate;
4
+ drawPolygon(gl: WebGLRenderingContext, projectionMatrix: Float32Array, cameraMatrix: Float32Array, targetMatrix: Float32Array, points: Float32Array): void;
5
+ }
@@ -0,0 +1,94 @@
1
+ import { compileShader, linkProgram } from "./shader";
2
+ let shader;
3
+ export class PolygonDraw {
4
+ _generate(gl, points) {
5
+ if (!this._vbo) {
6
+ this._vbo = gl.createBuffer();
7
+ }
8
+ if (!this._vbo)
9
+ throw new Error("Unable to create buffer object");
10
+ gl.bindBuffer(gl.ARRAY_BUFFER, this._vbo);
11
+ gl.bufferData(gl.ARRAY_BUFFER, points, gl.DYNAMIC_DRAW);
12
+ gl.bindBuffer(gl.ARRAY_BUFFER, null);
13
+ return this._vbo;
14
+ }
15
+ drawPolygon(gl, projectionMatrix, cameraMatrix, targetMatrix, points) {
16
+ let shader = getShader(gl);
17
+ let v = this._generate(gl, points);
18
+ gl.disable(gl.DEPTH_TEST);
19
+ gl.disable(gl.SCISSOR_TEST);
20
+ gl.disable(gl.CULL_FACE);
21
+ gl.disable(gl.STENCIL_TEST);
22
+ gl.disable(gl.BLEND);
23
+ gl.useProgram(shader.prog);
24
+ gl.uniformMatrix4fv(shader.unif_proj, false, projectionMatrix);
25
+ gl.uniformMatrix4fv(shader.unif_camera, false, cameraMatrix);
26
+ gl.uniformMatrix4fv(shader.unif_matrix, false, targetMatrix);
27
+ gl.bindBuffer(gl.ARRAY_BUFFER, v);
28
+ gl.vertexAttribPointer(shader.attr_position, 2, gl.FLOAT, false, 0, 0);
29
+ gl.enableVertexAttribArray(shader.attr_position);
30
+ gl.drawArrays(gl.LINE_LOOP, 0, points.length / 2);
31
+ gl.disableVertexAttribArray(shader.attr_position);
32
+ gl.bindBuffer(gl.ARRAY_BUFFER, null);
33
+ }
34
+ }
35
+ let vertexShaderSrc = `
36
+ #ifndef GL_ES
37
+ #define highp
38
+ #define mediump
39
+ #define lowp
40
+ #endif
41
+
42
+ uniform mat4 projMatrix;
43
+ uniform mat4 cameraMatrix;
44
+ uniform mat4 modelViewMatrix;
45
+ attribute vec2 position;
46
+
47
+ void main()
48
+ {
49
+ gl_Position = projMatrix * cameraMatrix * modelViewMatrix * vec4(position.x, 0.0, position.y, 1.0);
50
+ }`;
51
+ let fragmentShaderSrc = `
52
+ #define highp mediump
53
+ #ifdef GL_ES
54
+ // define default precision for float, vec, mat.
55
+ precision highp float;
56
+ #else
57
+ #define highp
58
+ #define mediump
59
+ #define lowp
60
+ #endif
61
+
62
+ void main()
63
+ {
64
+ gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
65
+ }`;
66
+ function getShader(gl) {
67
+ if (shader)
68
+ return shader;
69
+ let prog = gl.createProgram();
70
+ if (!prog)
71
+ throw new Error("Unable to create program");
72
+ let vertexShader = compileShader(gl, gl.VERTEX_SHADER, vertexShaderSrc);
73
+ let fragmentShader = compileShader(gl, gl.FRAGMENT_SHADER, fragmentShaderSrc);
74
+ gl.attachShader(prog, vertexShader);
75
+ gl.attachShader(prog, fragmentShader);
76
+ linkProgram(gl, prog);
77
+ let unif_proj = gl.getUniformLocation(prog, "projMatrix");
78
+ if (!unif_proj)
79
+ throw new Error("Unable to get uniform location projMatrix");
80
+ let unif_matrix = gl.getUniformLocation(prog, "modelViewMatrix");
81
+ if (!unif_matrix)
82
+ throw new Error("Unable to get uniform location modelViewMatrix");
83
+ let unif_camera = gl.getUniformLocation(prog, "cameraMatrix");
84
+ if (!unif_camera)
85
+ throw new Error("Unable to get uniform location cameraMatrix");
86
+ shader = {
87
+ prog,
88
+ unif_matrix,
89
+ unif_proj,
90
+ unif_camera,
91
+ attr_position: gl.getAttribLocation(prog, "position"),
92
+ };
93
+ return shader;
94
+ }
@@ -5,10 +5,16 @@ 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
  export { image_target_type_t } from "./zappar-native";
11
15
  export { world_tracker_quality_t } from "./zappar-native";
16
+ import { anchor_status_t } from "./zappar-native";
17
+ export { anchor_status_t } from "./zappar-native";
12
18
  export { camera_profile_t } from "./zappar-native";
13
19
  export declare type zappar_pipeline_t = number & {
14
20
  _: 'zappar_pipeline_t';
@@ -43,6 +49,9 @@ export declare type zappar_zapcode_tracker_t = number & {
43
49
  export declare type zappar_world_tracker_t = number & {
44
50
  _: 'zappar_world_tracker_t';
45
51
  };
52
+ export declare type zappar_custom_anchor_t = number & {
53
+ _: 'zappar_custom_anchor_t';
54
+ };
46
55
  export interface zappar {
47
56
  log_level(): log_level_t;
48
57
  log_level_set(level: log_level_t): void;
@@ -123,13 +132,23 @@ export interface zappar {
123
132
  world_tracker_enabled(o: zappar_world_tracker_t): boolean;
124
133
  world_tracker_enabled_set(o: zappar_world_tracker_t, enabled: boolean): void;
125
134
  world_tracker_quality(o: zappar_world_tracker_t): number;
126
- world_tracker_plane_detection_enabled(o: zappar_world_tracker_t): boolean;
127
- world_tracker_plane_detection_enabled_set(o: zappar_world_tracker_t, plane_detection_enabled: boolean): void;
128
- world_tracker_plane_count(o: zappar_world_tracker_t): number;
129
- world_tracker_plane_pose_raw(o: zappar_world_tracker_t, indx: number): Float32Array;
130
- world_tracker_world_anchor_valid(o: zappar_world_tracker_t): boolean;
135
+ world_tracker_horizontal_plane_detection_enabled(o: zappar_world_tracker_t): boolean;
136
+ world_tracker_horizontal_plane_detection_enabled_set(o: zappar_world_tracker_t, horizontal_plane_detection_enabled: boolean): void;
137
+ world_tracker_vertical_plane_detection_enabled(o: zappar_world_tracker_t): boolean;
138
+ world_tracker_vertical_plane_detection_enabled_set(o: zappar_world_tracker_t, vertical_plane_detection_enabled: boolean): void;
139
+ world_tracker_plane_anchor_count(o: zappar_world_tracker_t): number;
140
+ world_tracker_plane_anchor_id(o: zappar_world_tracker_t, indx: number): string;
141
+ world_tracker_plane_anchor_pose_raw(o: zappar_world_tracker_t, indx: number): Float32Array;
142
+ world_tracker_plane_anchor_status(o: zappar_world_tracker_t, indx: number): anchor_status_t;
143
+ world_tracker_plane_anchor_polygon_data_size(o: zappar_world_tracker_t, indx: number): number;
144
+ world_tracker_plane_anchor_polygon_data(o: zappar_world_tracker_t, indx: number): Float32Array;
145
+ world_tracker_plane_anchor_polygon_version(o: zappar_world_tracker_t, indx: number): number;
146
+ world_tracker_plane_anchor_orientation(o: zappar_world_tracker_t, indx: number): plane_orientation_t;
147
+ world_tracker_world_anchor_status(o: zappar_world_tracker_t): anchor_status_t;
148
+ world_tracker_world_anchor_id(o: zappar_world_tracker_t): string;
131
149
  world_tracker_world_anchor_pose_raw(o: zappar_world_tracker_t): Float32Array;
132
- world_tracker_ground_anchor_valid(o: zappar_world_tracker_t): boolean;
150
+ world_tracker_ground_anchor_id(o: zappar_world_tracker_t): string;
151
+ world_tracker_ground_anchor_status(o: zappar_world_tracker_t): anchor_status_t;
133
152
  world_tracker_ground_anchor_pose_raw(o: zappar_world_tracker_t): Float32Array;
134
153
  world_tracker_reset(o: zappar_world_tracker_t): void;
135
154
  world_tracker_tracks_data_enabled(o: zappar_world_tracker_t): boolean;
@@ -142,4 +161,12 @@ export interface zappar {
142
161
  world_tracker_projections_data_enabled_set(o: zappar_world_tracker_t, projections_data_enabled: boolean): void;
143
162
  world_tracker_projections_data_size(o: zappar_world_tracker_t): number;
144
163
  world_tracker_projections_data(o: zappar_world_tracker_t): Float32Array;
164
+ custom_anchor_create(pipeline: zappar_pipeline_t, worldtracker: zappar_world_tracker_t, id: string): zappar_custom_anchor_t;
165
+ custom_anchor_destroy(o: zappar_custom_anchor_t): void;
166
+ custom_anchor_status(o: zappar_custom_anchor_t): anchor_status_t;
167
+ custom_anchor_enabled_set(o: zappar_custom_anchor_t, enabled: boolean): void;
168
+ custom_anchor_enabled(o: zappar_custom_anchor_t): boolean;
169
+ custom_anchor_pose_raw(o: zappar_custom_anchor_t): Float32Array;
170
+ custom_anchor_pose_set_from_camera_offset_raw(o: zappar_custom_anchor_t, x: number, y: number, z: number, orientation: transform_orientation_t): void;
171
+ 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;
145
172
  }
@@ -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";
@@ -19,6 +19,7 @@ export declare class zappar_client {
19
19
  private _instant_world_tracker_state_by_instance;
20
20
  private _zapcode_tracker_state_by_instance;
21
21
  private _world_tracker_state_by_instance;
22
+ private _custom_anchor_state_by_instance;
22
23
  impl: zappar;
23
24
  processMessages(a: ArrayBuffer): void;
24
25
  }