@zappar/zappar-cv 3.0.1-alpha.1 → 3.0.1-alpha.2
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/additional.d.ts +3 -0
- package/lib/camera-frame-data.d.ts +5 -0
- package/lib/camera-frame-data.js +1 -0
- package/lib/gen/zappar-bridge.d.ts +120 -0
- package/lib/gen/zappar-bridge.js +7 -0
- package/lib/gen/zappar-client.d.ts +2 -2
- package/lib/gen/zappar-client.js +0 -5
- package/lib/gen/zappar-cwrap.js +28 -0
- package/lib/gen/zappar-native.d.ts +4 -0
- package/lib/gen/zappar.d.ts +1 -0
- package/lib/html-element-source.js +1 -0
- package/lib/imagetracker.d.ts +3 -2
- package/lib/index.d.ts +1 -0
- package/lib/native.js +17 -3
- package/lib/pipeline.d.ts +11 -3
- package/lib/pipeline.js +72 -3
- package/lib/source.d.ts +1 -0
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/lib/worker-server.js +48 -3
- package/lib/workerinterface.d.ts +16 -0
- package/lib/zappar-cv.js +103 -102
- package/lib/zappar-cv.wasm +0 -0
- package/package.json +1 -1
- package/umd/{501114eb92cddf5f56fe.wasm → 36d6b6985808cbeca829.wasm} +0 -0
- package/umd/429.zappar-cv.js +1 -1
- package/umd/867.zappar-cv.js +1 -1
- package/umd/zappar-cv.js +1 -1
- package/umd/zappar-cv.worker.js +1 -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.0.1-alpha.
|
|
21
|
+
<script src="https://libs.zappar.com/zappar-cv/3.0.1-alpha.2/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.
|
|
25
|
+
[https://libs.zappar.com/zappar-cv/3.0.1-alpha.2/zappar-cv.zip](https://libs.zappar.com/zappar-cv/3.0.1-alpha.2/zappar-cv.zip)
|
package/lib/additional.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CameraFrameData } from "./camera-frame-data";
|
|
1
2
|
import { zappar_face_mesh_t, zappar_face_tracker_t, zappar_pipeline_t, zappar_image_tracker_t, zappar_sequence_source_t } from "./gen/zappar";
|
|
2
3
|
export declare type zappar_html_element_source_t = number & {
|
|
3
4
|
_: 'zappar_html_element_source_t';
|
|
@@ -8,6 +9,8 @@ export interface Additional {
|
|
|
8
9
|
pipeline_draw_face(pipeline: zappar_pipeline_t, projectionMatrix: Float32Array, cameraMatrix: Float32Array, targetMatrix: Float32Array, o: zappar_face_mesh_t): void;
|
|
9
10
|
pipeline_draw_image_target_preview(pipeline: zappar_pipeline_t, projectionMatrix: Float32Array, cameraMatrix: Float32Array, targetMatrix: Float32Array, o: zappar_image_tracker_t, indx: number): void;
|
|
10
11
|
pipeline_draw_face_project(pipeline: zappar_pipeline_t, drawwMatrix: Float32Array, vertices: Float32Array, uvMatrix: Float32Array, uvs: Float32Array, indices: Uint16Array, texture: WebGLTexture): void;
|
|
12
|
+
pipeline_camera_frame_data_raw_enabled_set(pipeline: zappar_pipeline_t, enabled: boolean): void;
|
|
13
|
+
pipeline_camera_frame_data_raw(pipeline: zappar_pipeline_t): Promise<CameraFrameData | undefined>;
|
|
11
14
|
draw_plane(gl: WebGLRenderingContext, projectionMatrix: Float32Array, cameraMatrix: Float32Array, targetMatrix: Float32Array, texture: string): void;
|
|
12
15
|
image_tracker_target_image(o: zappar_image_tracker_t, indx: number): HTMLImageElement | undefined;
|
|
13
16
|
face_mesh_load_default(o: zappar_face_mesh_t): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { barcode_format_t } from "./zappar-native";
|
|
2
|
+
export { barcode_format_t } from "./zappar-native";
|
|
3
|
+
import { face_landmark_name_t } from "./zappar-native";
|
|
4
|
+
export { face_landmark_name_t } from "./zappar-native";
|
|
5
|
+
export { frame_pixel_format_t } from "./zappar-native";
|
|
6
|
+
import { instant_world_tracker_transform_orientation_t } from "./zappar-native";
|
|
7
|
+
export { instant_world_tracker_transform_orientation_t } from "./zappar-native";
|
|
8
|
+
import { log_level_t } from "./zappar-native";
|
|
9
|
+
export { log_level_t } from "./zappar-native";
|
|
10
|
+
export { image_target_type_t } from "./zappar-native";
|
|
11
|
+
export { world_tracker_quality_t } from "./zappar-native";
|
|
12
|
+
export declare type zappar_pipeline_t = number & {
|
|
13
|
+
_: 'zappar_pipeline_t';
|
|
14
|
+
};
|
|
15
|
+
export declare type zappar_camera_source_t = number & {
|
|
16
|
+
_: 'zappar_camera_source_t';
|
|
17
|
+
};
|
|
18
|
+
export declare type zappar_sequence_source_t = number & {
|
|
19
|
+
_: 'zappar_sequence_source_t';
|
|
20
|
+
};
|
|
21
|
+
export declare type zappar_image_tracker_t = number & {
|
|
22
|
+
_: 'zappar_image_tracker_t';
|
|
23
|
+
};
|
|
24
|
+
export declare type zappar_face_tracker_t = number & {
|
|
25
|
+
_: 'zappar_face_tracker_t';
|
|
26
|
+
};
|
|
27
|
+
export declare type zappar_face_mesh_t = number & {
|
|
28
|
+
_: 'zappar_face_mesh_t';
|
|
29
|
+
};
|
|
30
|
+
export declare type zappar_face_landmark_t = number & {
|
|
31
|
+
_: 'zappar_face_landmark_t';
|
|
32
|
+
};
|
|
33
|
+
export declare type zappar_barcode_finder_t = number & {
|
|
34
|
+
_: 'zappar_barcode_finder_t';
|
|
35
|
+
};
|
|
36
|
+
export declare type zappar_instant_world_tracker_t = number & {
|
|
37
|
+
_: 'zappar_instant_world_tracker_t';
|
|
38
|
+
};
|
|
39
|
+
export declare type zappar_world_tracker_t = number & {
|
|
40
|
+
_: 'zappar_world_tracker_t';
|
|
41
|
+
};
|
|
42
|
+
export interface zappar {
|
|
43
|
+
log_level(): log_level_t;
|
|
44
|
+
log_level_set(level: log_level_t): void;
|
|
45
|
+
analytics_project_id_set(id: string, uid: string): void;
|
|
46
|
+
pipeline_create(): zappar_pipeline_t;
|
|
47
|
+
pipeline_destroy(o: zappar_pipeline_t): void;
|
|
48
|
+
pipeline_frame_update(o: zappar_pipeline_t): void;
|
|
49
|
+
pipeline_frame_number(o: zappar_pipeline_t): number;
|
|
50
|
+
pipeline_camera_model(o: zappar_pipeline_t): Float32Array;
|
|
51
|
+
pipeline_camera_frame_user_data(o: zappar_pipeline_t): number;
|
|
52
|
+
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;
|
|
53
|
+
pipeline_camera_frame_camera_attitude(o: zappar_pipeline_t): Float32Array;
|
|
54
|
+
pipeline_camera_frame_device_attitude(o: zappar_pipeline_t): Float32Array;
|
|
55
|
+
pipeline_motion_accelerometer_submit(o: zappar_pipeline_t, time: number, x: number, y: number, z: number): void;
|
|
56
|
+
pipeline_motion_accelerometer_with_gravity_submit_int(o: zappar_pipeline_t, time: number, interval: number, x: number, y: number, z: number): void;
|
|
57
|
+
pipeline_motion_accelerometer_without_gravity_submit_int(o: zappar_pipeline_t, time: number, interval: number, x: number, y: number, z: number): void;
|
|
58
|
+
pipeline_motion_rotation_rate_submit(o: zappar_pipeline_t, time: number, x: number, y: number, z: number): void;
|
|
59
|
+
pipeline_motion_rotation_rate_submit_int(o: zappar_pipeline_t, time: number, interval: number, x: number, y: number, z: number): void;
|
|
60
|
+
pipeline_motion_attitude_submit(o: zappar_pipeline_t, time: number, x: number, y: number, z: number): void;
|
|
61
|
+
pipeline_motion_attitude_submit_int(o: zappar_pipeline_t, time: number, interval: number, x: number, y: number, z: number): void;
|
|
62
|
+
pipeline_motion_attitude_matrix_submit(o: zappar_pipeline_t, mat: Float32Array): void;
|
|
63
|
+
camera_source_create(pipeline: zappar_pipeline_t, device_id: string): zappar_camera_source_t;
|
|
64
|
+
camera_source_destroy(o: zappar_camera_source_t): void;
|
|
65
|
+
sequence_source_create(pipeline: zappar_pipeline_t): zappar_sequence_source_t;
|
|
66
|
+
sequence_source_destroy(o: zappar_sequence_source_t): void;
|
|
67
|
+
image_tracker_create(pipeline: zappar_pipeline_t): zappar_image_tracker_t;
|
|
68
|
+
image_tracker_destroy(o: zappar_image_tracker_t): void;
|
|
69
|
+
image_tracker_target_load_from_memory(o: zappar_image_tracker_t, data: ArrayBuffer): void;
|
|
70
|
+
image_tracker_target_loaded_version(o: zappar_image_tracker_t): number;
|
|
71
|
+
image_tracker_enabled(o: zappar_image_tracker_t): boolean;
|
|
72
|
+
image_tracker_enabled_set(o: zappar_image_tracker_t, enabled: boolean): void;
|
|
73
|
+
image_tracker_anchor_count(o: zappar_image_tracker_t): number;
|
|
74
|
+
image_tracker_anchor_id(o: zappar_image_tracker_t, indx: number): string;
|
|
75
|
+
image_tracker_anchor_pose_raw(o: zappar_image_tracker_t, indx: number): Float32Array;
|
|
76
|
+
face_tracker_create(pipeline: zappar_pipeline_t): zappar_face_tracker_t;
|
|
77
|
+
face_tracker_destroy(o: zappar_face_tracker_t): void;
|
|
78
|
+
face_tracker_model_load_from_memory(o: zappar_face_tracker_t, data: ArrayBuffer): void;
|
|
79
|
+
face_tracker_model_loaded_version(o: zappar_face_tracker_t): number;
|
|
80
|
+
face_tracker_enabled_set(o: zappar_face_tracker_t, enabled: boolean): void;
|
|
81
|
+
face_tracker_enabled(o: zappar_face_tracker_t): boolean;
|
|
82
|
+
face_tracker_max_faces_set(o: zappar_face_tracker_t, num: number): void;
|
|
83
|
+
face_tracker_max_faces(o: zappar_face_tracker_t): number;
|
|
84
|
+
face_tracker_anchor_count(o: zappar_face_tracker_t): number;
|
|
85
|
+
face_tracker_anchor_id(o: zappar_face_tracker_t, indx: number): string;
|
|
86
|
+
face_tracker_anchor_pose_raw(o: zappar_face_tracker_t, indx: number): Float32Array;
|
|
87
|
+
face_tracker_anchor_identity_coefficients(o: zappar_face_tracker_t, indx: number): Float32Array;
|
|
88
|
+
face_tracker_anchor_expression_coefficients(o: zappar_face_tracker_t, indx: number): Float32Array;
|
|
89
|
+
face_mesh_create(): zappar_face_mesh_t;
|
|
90
|
+
face_mesh_destroy(o: zappar_face_mesh_t): void;
|
|
91
|
+
face_landmark_create(landmark: face_landmark_name_t): zappar_face_landmark_t;
|
|
92
|
+
face_landmark_destroy(o: zappar_face_landmark_t): void;
|
|
93
|
+
barcode_finder_create(pipeline: zappar_pipeline_t): zappar_barcode_finder_t;
|
|
94
|
+
barcode_finder_destroy(o: zappar_barcode_finder_t): void;
|
|
95
|
+
barcode_finder_enabled_set(o: zappar_barcode_finder_t, enabled: boolean): void;
|
|
96
|
+
barcode_finder_enabled(o: zappar_barcode_finder_t): boolean;
|
|
97
|
+
barcode_finder_found_number(o: zappar_barcode_finder_t): number;
|
|
98
|
+
barcode_finder_found_text(o: zappar_barcode_finder_t, indx: number): string;
|
|
99
|
+
barcode_finder_found_format(o: zappar_barcode_finder_t, indx: number): barcode_format_t;
|
|
100
|
+
barcode_finder_formats(o: zappar_barcode_finder_t): barcode_format_t;
|
|
101
|
+
barcode_finder_formats_set(o: zappar_barcode_finder_t, f: barcode_format_t): void;
|
|
102
|
+
instant_world_tracker_create(pipeline: zappar_pipeline_t): zappar_instant_world_tracker_t;
|
|
103
|
+
instant_world_tracker_destroy(o: zappar_instant_world_tracker_t): void;
|
|
104
|
+
instant_world_tracker_enabled_set(o: zappar_instant_world_tracker_t, enabled: boolean): void;
|
|
105
|
+
instant_world_tracker_enabled(o: zappar_instant_world_tracker_t): boolean;
|
|
106
|
+
instant_world_tracker_anchor_pose_raw(o: zappar_instant_world_tracker_t): Float32Array;
|
|
107
|
+
instant_world_tracker_anchor_pose_set_from_camera_offset_raw(o: zappar_instant_world_tracker_t, x: number, y: number, z: number, orientation: instant_world_tracker_transform_orientation_t): void;
|
|
108
|
+
world_tracker_create(pipeline: zappar_pipeline_t): zappar_world_tracker_t;
|
|
109
|
+
world_tracker_destroy(o: zappar_world_tracker_t): void;
|
|
110
|
+
world_tracker_enabled(o: zappar_world_tracker_t): boolean;
|
|
111
|
+
world_tracker_enabled_set(o: zappar_world_tracker_t, enabled: boolean): void;
|
|
112
|
+
world_tracker_quality(o: zappar_world_tracker_t): number;
|
|
113
|
+
world_tracker_plane_count(o: zappar_world_tracker_t): number;
|
|
114
|
+
world_tracker_plane_pose_raw(o: zappar_world_tracker_t, indx: number): Float32Array;
|
|
115
|
+
world_tracker_world_anchor_valid(o: zappar_world_tracker_t): boolean;
|
|
116
|
+
world_tracker_world_anchor_pose_raw(o: zappar_world_tracker_t): Float32Array;
|
|
117
|
+
world_tracker_ground_anchor_valid(o: zappar_world_tracker_t): boolean;
|
|
118
|
+
world_tracker_ground_anchor_pose_raw(o: zappar_world_tracker_t): Float32Array;
|
|
119
|
+
world_tracker_reset(o: zappar_world_tracker_t): void;
|
|
120
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { barcode_format_t } from "./zappar-native";
|
|
2
|
+
export { face_landmark_name_t } from "./zappar-native";
|
|
3
|
+
export { frame_pixel_format_t } from "./zappar-native";
|
|
4
|
+
export { instant_world_tracker_transform_orientation_t } from "./zappar-native";
|
|
5
|
+
export { log_level_t } from "./zappar-native";
|
|
6
|
+
export { image_target_type_t } from "./zappar-native";
|
|
7
|
+
export { world_tracker_quality_t } from "./zappar-native";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MessageSerializer } from "../serializer";
|
|
2
2
|
import { MessageDeserializer } from "../deserializer";
|
|
3
|
-
import {
|
|
3
|
+
import { zappar } from "./zappar-bridge";
|
|
4
4
|
export declare class zappar_client {
|
|
5
5
|
private _messageSender;
|
|
6
6
|
constructor(_messageSender: (ab: ArrayBuffer) => void);
|
|
@@ -18,6 +18,6 @@ export declare class zappar_client {
|
|
|
18
18
|
private _barcode_finder_state_by_instance;
|
|
19
19
|
private _instant_world_tracker_state_by_instance;
|
|
20
20
|
private _world_tracker_state_by_instance;
|
|
21
|
-
impl:
|
|
21
|
+
impl: zappar;
|
|
22
22
|
processMessages(a: ArrayBuffer): void;
|
|
23
23
|
}
|
package/lib/gen/zappar-client.js
CHANGED
|
@@ -103,11 +103,6 @@ export class zappar_client {
|
|
|
103
103
|
m.bool(user_facing);
|
|
104
104
|
});
|
|
105
105
|
},
|
|
106
|
-
pipeline_camera_frame_submit_raw_pointer: (o, data, dataLength, format, width, height, user_data, camera_to_device_transform, rotation, camera_model, user_facing, timestamp) => {
|
|
107
|
-
let s = this._pipeline_state_by_instance.get(o);
|
|
108
|
-
if (!s)
|
|
109
|
-
throw new Error("This object has been destroyed");
|
|
110
|
-
},
|
|
111
106
|
pipeline_camera_frame_camera_attitude: (o) => {
|
|
112
107
|
let s = this._pipeline_state_by_instance.get(o);
|
|
113
108
|
if (!s)
|
package/lib/gen/zappar-cwrap.js
CHANGED
|
@@ -8,6 +8,18 @@ export function getRuntimeObject(mod) {
|
|
|
8
8
|
]);
|
|
9
9
|
let pipeline_create_wrapped = mod.cwrap("zappar_pipeline_create", "number", []);
|
|
10
10
|
let pipeline_destroy_wrapped = mod.cwrap("zappar_pipeline_destroy", null, ["number"]);
|
|
11
|
+
let pipeline_camera_frame_data_raw_wrapped = mod.cwrap("zappar_pipeline_camera_frame_data_raw", "number", [
|
|
12
|
+
"number"
|
|
13
|
+
]);
|
|
14
|
+
let pipeline_camera_frame_data_raw_size_wrapped = mod.cwrap("zappar_pipeline_camera_frame_data_raw_size", "number", [
|
|
15
|
+
"number"
|
|
16
|
+
]);
|
|
17
|
+
let pipeline_camera_frame_data_raw_width_wrapped = mod.cwrap("zappar_pipeline_camera_frame_data_raw_width", "number", [
|
|
18
|
+
"number"
|
|
19
|
+
]);
|
|
20
|
+
let pipeline_camera_frame_data_raw_height_wrapped = mod.cwrap("zappar_pipeline_camera_frame_data_raw_height", "number", [
|
|
21
|
+
"number"
|
|
22
|
+
]);
|
|
11
23
|
let pipeline_frame_update_wrapped = mod.cwrap("zappar_pipeline_frame_update", null, [
|
|
12
24
|
"number"
|
|
13
25
|
]);
|
|
@@ -257,6 +269,22 @@ export function getRuntimeObject(mod) {
|
|
|
257
269
|
pipeline_destroy: () => {
|
|
258
270
|
pipeline_destroy_wrapped();
|
|
259
271
|
},
|
|
272
|
+
pipeline_camera_frame_data_raw: (o) => {
|
|
273
|
+
let ret = pipeline_camera_frame_data_raw_wrapped(o);
|
|
274
|
+
return ret;
|
|
275
|
+
},
|
|
276
|
+
pipeline_camera_frame_data_raw_size: (o) => {
|
|
277
|
+
let ret = pipeline_camera_frame_data_raw_size_wrapped(o);
|
|
278
|
+
return ret;
|
|
279
|
+
},
|
|
280
|
+
pipeline_camera_frame_data_raw_width: (o) => {
|
|
281
|
+
let ret = pipeline_camera_frame_data_raw_width_wrapped(o);
|
|
282
|
+
return ret;
|
|
283
|
+
},
|
|
284
|
+
pipeline_camera_frame_data_raw_height: (o) => {
|
|
285
|
+
let ret = pipeline_camera_frame_data_raw_height_wrapped(o);
|
|
286
|
+
return ret;
|
|
287
|
+
},
|
|
260
288
|
pipeline_frame_update: (o) => {
|
|
261
289
|
let ret = pipeline_frame_update_wrapped(o);
|
|
262
290
|
return ret;
|
|
@@ -102,6 +102,10 @@ export interface zappar_cwrap {
|
|
|
102
102
|
analytics_project_id_set(id: string, uid: string): void;
|
|
103
103
|
pipeline_create(): zappar_pipeline_t;
|
|
104
104
|
pipeline_destroy(o: zappar_pipeline_t): void;
|
|
105
|
+
pipeline_camera_frame_data_raw(o: zappar_pipeline_t): number;
|
|
106
|
+
pipeline_camera_frame_data_raw_size(o: zappar_pipeline_t): number;
|
|
107
|
+
pipeline_camera_frame_data_raw_width(o: zappar_pipeline_t): number;
|
|
108
|
+
pipeline_camera_frame_data_raw_height(o: zappar_pipeline_t): number;
|
|
105
109
|
pipeline_frame_update(o: zappar_pipeline_t): void;
|
|
106
110
|
pipeline_frame_number(o: zappar_pipeline_t): number;
|
|
107
111
|
pipeline_camera_model(o: zappar_pipeline_t): Float32Array;
|
package/lib/gen/zappar.d.ts
CHANGED
|
@@ -49,6 +49,7 @@ export interface zappar {
|
|
|
49
49
|
camera_user_facing(indx: number): boolean;
|
|
50
50
|
projection_matrix_from_camera_model(model: Float32Array, renderWidth: number, renderHeight: number): Float32Array;
|
|
51
51
|
projection_matrix_from_camera_model_ext(model: Float32Array, renderWidth: number, renderHeight: number, zNear: number, zFar: number): Float32Array;
|
|
52
|
+
pose_from_raw(raw_pose: Float32Array, mirror: boolean): Float32Array;
|
|
52
53
|
log_level(): log_level_t;
|
|
53
54
|
log_level_set(level: log_level_t): void;
|
|
54
55
|
permission_request_ui(): void;
|
|
@@ -89,6 +89,7 @@ export class HTMLElementSource extends Source {
|
|
|
89
89
|
if (info) {
|
|
90
90
|
let token = pipeline.registerToken(info);
|
|
91
91
|
pipeline.sendDataToWorker(info.data || new ArrayBuffer(0), token, info.dataWidth, info.dataHeight, info.userFacing, info.cameraToDevice, info.cameraModel);
|
|
92
|
+
info.data = undefined;
|
|
92
93
|
}
|
|
93
94
|
}
|
|
94
95
|
catch (ex) {
|
package/lib/imagetracker.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { zappar_image_tracker_t, zappar_pipeline_t } from "./gen/zappar";
|
|
2
|
-
import {
|
|
2
|
+
import { zappar } from "./gen/zappar-bridge";
|
|
3
|
+
import { image_target_type_t } from "./gen/zappar-native";
|
|
3
4
|
interface PreviewInfo {
|
|
4
5
|
compressed: Uint8Array;
|
|
5
6
|
mimeType: string;
|
|
@@ -26,7 +27,7 @@ export declare class ImageTracker {
|
|
|
26
27
|
private _client;
|
|
27
28
|
private _impl;
|
|
28
29
|
private _targets;
|
|
29
|
-
static create(pipeline: zappar_pipeline_t, client:
|
|
30
|
+
static create(pipeline: zappar_pipeline_t, client: zappar): zappar_image_tracker_t;
|
|
30
31
|
static get(p: zappar_image_tracker_t): ImageTracker | undefined;
|
|
31
32
|
private constructor();
|
|
32
33
|
destroy(): void;
|
package/lib/index.d.ts
CHANGED
|
@@ -3,4 +3,5 @@ import { Additional } from "./additional";
|
|
|
3
3
|
import { Options } from "./options";
|
|
4
4
|
export declare type Zappar = zappar & Additional;
|
|
5
5
|
export declare function initialize(opts?: Options): Zappar;
|
|
6
|
+
export { CameraFrameData } from './camera-frame-data';
|
|
6
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, 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 } from "./gen/zappar";
|
package/lib/native.js
CHANGED
|
@@ -49,7 +49,7 @@ export function initialize(opts) {
|
|
|
49
49
|
c.impl.analytics_project_id_set(".wiz" + pathParts[1], uid);
|
|
50
50
|
}
|
|
51
51
|
messageManager.onIncomingMessage.bind(msg => {
|
|
52
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
52
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
53
53
|
switch (msg.t) {
|
|
54
54
|
case "zappar":
|
|
55
55
|
(_a = Pipeline.get(msg.p)) === null || _a === void 0 ? void 0 : _a.pendingMessages.push(msg.d);
|
|
@@ -72,6 +72,11 @@ export function initialize(opts) {
|
|
|
72
72
|
(_g = (_f = Pipeline.get(msgt.p)) === null || _f === void 0 ? void 0 : _f.imageBitmapFromWorker) === null || _g === void 0 ? void 0 : _g.call(_f, msgt);
|
|
73
73
|
break;
|
|
74
74
|
}
|
|
75
|
+
case "raw": {
|
|
76
|
+
let msgt = msg;
|
|
77
|
+
(_h = Pipeline.get(msgt.p)) === null || _h === void 0 ? void 0 : _h.cameraFrameDataRawResult(msgt);
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
75
80
|
case "streamEndedS2C": {
|
|
76
81
|
let msgt = msg;
|
|
77
82
|
const src = getCameraSource(msgt.source);
|
|
@@ -132,7 +137,16 @@ export function initialize(opts) {
|
|
|
132
137
|
}
|
|
133
138
|
}
|
|
134
139
|
});
|
|
135
|
-
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_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,
|
|
140
|
+
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_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) => {
|
|
141
|
+
let res = applyScreenCounterRotation(undefined, raw_pose);
|
|
142
|
+
if (mirror) {
|
|
143
|
+
let scale = mat4.create();
|
|
144
|
+
mat4.fromScaling(scale, [-1, 1, 1]);
|
|
145
|
+
mat4.multiply(res, scale, res);
|
|
146
|
+
mat4.multiply(res, res, scale);
|
|
147
|
+
}
|
|
148
|
+
return res;
|
|
149
|
+
}, pipeline_create: () => Pipeline.create(c.impl, messageManager), pipeline_frame_update: (p) => { var _a; return (_a = Pipeline.get(p)) === null || _a === void 0 ? void 0 : _a.frameUpdate(c); }, pipeline_camera_frame_draw_gl: (pipeline, screenWidth, screenHeight, mirror) => {
|
|
136
150
|
var _a;
|
|
137
151
|
(_a = Pipeline.get(pipeline)) === null || _a === void 0 ? void 0 : _a.cameraFrameDrawGL(screenWidth, screenHeight, mirror);
|
|
138
152
|
}, draw_plane: (gl, projectionMatrix, cameraMatrix, targetMatrix, texture) => {
|
|
@@ -156,7 +170,7 @@ export function initialize(opts) {
|
|
|
156
170
|
return;
|
|
157
171
|
}
|
|
158
172
|
(_a = Pipeline.get(p)) === null || _a === void 0 ? void 0 : _a.drawImageTargetPreview(projectionMatrix, cameraMatrix, targetMatrix, indx, obj);
|
|
159
|
-
}, projection_matrix_from_camera_model: projectionMatrix, projection_matrix_from_camera_model_ext: projectionMatrix, pipeline_process_gl: p => { var _a; return (_a = Pipeline.get(p)) === null || _a === void 0 ? void 0 : _a.processGL(); }, pipeline_gl_context_set: (p, gl, texturePool) => { var _a; return (_a = Pipeline.get(p)) === null || _a === void 0 ? void 0 : _a.glContextSet(gl, texturePool); }, pipeline_gl_context_lost: (p) => { var _a; return (_a = Pipeline.get(p)) === null || _a === void 0 ? void 0 : _a.glContextLost(); }, pipeline_camera_frame_upload_gl: p => { var _a; return (_a = Pipeline.get(p)) === null || _a === void 0 ? void 0 : _a.uploadGL(); }, pipeline_camera_frame_texture_gl: p => { var _a; return (_a = Pipeline.get(p)) === null || _a === void 0 ? void 0 : _a.cameraFrameTexture(); }, pipeline_camera_frame_texture_matrix: (p, sw, sh, mirror) => { var _a; return ((_a = Pipeline.get(p)) === null || _a === void 0 ? void 0 : _a.cameraFrameTextureMatrix(sw, sh, mirror)) || mat4.create(); }, pipeline_camera_frame_user_facing: p => { var _a; return ((_a = Pipeline.get(p)) === null || _a === void 0 ? void 0 : _a.cameraFrameUserFacing()) || false; }, pipeline_camera_pose_default: () => mat4.create(), pipeline_camera_pose_with_attitude: (p, mirror) => { var _a; return ((_a = Pipeline.get(p)) === null || _a === void 0 ? void 0 : _a.cameraPoseWithAttitude(mirror)) || mat4.create(); }, pipeline_camera_pose_with_origin: (p, o) => { let res = mat4.create(); mat4.invert(res, o); return res; }, pipeline_sequence_record_clear: p => { var _a; return (_a = Pipeline.get(p)) === null || _a === void 0 ? void 0 : _a.sequenceRecordClear(); }, pipeline_sequence_record_start: (p, expectedFrames) => { var _a; return (_a = Pipeline.get(p)) === null || _a === void 0 ? void 0 : _a.sequenceRecordStart(expectedFrames); }, pipeline_sequence_record_stop: p => { var _a; return (_a = Pipeline.get(p)) === null || _a === void 0 ? void 0 : _a.sequenceRecordStop(); }, pipeline_sequence_record_device_attitude_matrices_set: (p, v) => { var _a; return (_a = Pipeline.get(p)) === null || _a === void 0 ? void 0 : _a.sequenceRecordDeviceAttitudeMatrices(v); }, pipeline_sequence_record_data: p => { var _a; return ((_a = Pipeline.get(p)) === null || _a === void 0 ? void 0 : _a.sequenceRecordData()) || new Uint8Array(0); }, pipeline_sequence_record_data_size: p => { var _a; return ((_a = Pipeline.get(p)) === null || _a === void 0 ? void 0 : _a.sequenceRecordData().byteLength) || 0; }, instant_world_tracker_anchor_pose_camera_relative: (o, mirror) => {
|
|
173
|
+
}, projection_matrix_from_camera_model: projectionMatrix, projection_matrix_from_camera_model_ext: projectionMatrix, pipeline_process_gl: p => { var _a; return (_a = Pipeline.get(p)) === null || _a === void 0 ? void 0 : _a.processGL(); }, pipeline_gl_context_set: (p, gl, texturePool) => { var _a; return (_a = Pipeline.get(p)) === null || _a === void 0 ? void 0 : _a.glContextSet(gl, texturePool); }, pipeline_gl_context_lost: (p) => { var _a; return (_a = Pipeline.get(p)) === null || _a === void 0 ? void 0 : _a.glContextLost(); }, pipeline_camera_frame_upload_gl: p => { var _a; return (_a = Pipeline.get(p)) === null || _a === void 0 ? void 0 : _a.uploadGL(); }, pipeline_camera_frame_texture_gl: p => { var _a; return (_a = Pipeline.get(p)) === null || _a === void 0 ? void 0 : _a.cameraFrameTexture(); }, pipeline_camera_frame_texture_matrix: (p, sw, sh, mirror) => { var _a; return ((_a = Pipeline.get(p)) === null || _a === void 0 ? void 0 : _a.cameraFrameTextureMatrix(sw, sh, mirror)) || mat4.create(); }, pipeline_camera_frame_user_facing: p => { var _a; return ((_a = Pipeline.get(p)) === null || _a === void 0 ? void 0 : _a.cameraFrameUserFacing()) || false; }, pipeline_camera_pose_default: () => mat4.create(), pipeline_camera_pose_with_attitude: (p, mirror) => { var _a; return ((_a = Pipeline.get(p)) === null || _a === void 0 ? void 0 : _a.cameraPoseWithAttitude(mirror)) || mat4.create(); }, pipeline_camera_pose_with_origin: (p, o) => { let res = mat4.create(); mat4.invert(res, o); return res; }, pipeline_sequence_record_clear: p => { var _a; return (_a = Pipeline.get(p)) === null || _a === void 0 ? void 0 : _a.sequenceRecordClear(); }, pipeline_sequence_record_start: (p, expectedFrames) => { var _a; return (_a = Pipeline.get(p)) === null || _a === void 0 ? void 0 : _a.sequenceRecordStart(expectedFrames); }, pipeline_sequence_record_stop: p => { var _a; return (_a = Pipeline.get(p)) === null || _a === void 0 ? void 0 : _a.sequenceRecordStop(); }, pipeline_sequence_record_device_attitude_matrices_set: (p, v) => { var _a; return (_a = Pipeline.get(p)) === null || _a === void 0 ? void 0 : _a.sequenceRecordDeviceAttitudeMatrices(v); }, pipeline_sequence_record_data: p => { var _a; return ((_a = Pipeline.get(p)) === null || _a === void 0 ? void 0 : _a.sequenceRecordData()) || new Uint8Array(0); }, pipeline_sequence_record_data_size: p => { var _a; return ((_a = Pipeline.get(p)) === null || _a === void 0 ? void 0 : _a.sequenceRecordData().byteLength) || 0; }, pipeline_camera_frame_data_raw: p => { var _a; return ((_a = Pipeline.get(p)) === null || _a === void 0 ? void 0 : _a.getCameraFrameDataRaw()) || Promise.reject(); }, pipeline_camera_frame_data_raw_enabled_set: (p, v) => { var _a; return (_a = Pipeline.get(p)) === null || _a === void 0 ? void 0 : _a.setCameraFrameDataRawEnabled(v); }, instant_world_tracker_anchor_pose_camera_relative: (o, mirror) => {
|
|
160
174
|
let res = applyScreenCounterRotation(undefined, c.impl.instant_world_tracker_anchor_pose_raw(o));
|
|
161
175
|
if (mirror) {
|
|
162
176
|
let scale = mat4.create();
|
package/lib/pipeline.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
/// <reference types="dom-webcodecs" />
|
|
2
2
|
import { zappar_pipeline_t, zappar_camera_source_t } from "./gen/zappar";
|
|
3
|
-
import { zappar_cwrap } from "./gen/zappar-native";
|
|
4
3
|
import { zappar_client } from "./gen/zappar-client";
|
|
5
4
|
import { MsgManager } from "./messages";
|
|
6
5
|
import { Source, CameraFrameInfo } from "./source";
|
|
7
|
-
import { CameraFrameReturnS2C, ImageBitmapS2C, VideoFrameS2C } from "./workerinterface";
|
|
6
|
+
import { CameraDataRawS2C, CameraFrameReturnS2C, ImageBitmapS2C, VideoFrameS2C } from "./workerinterface";
|
|
8
7
|
import { FaceMesh } from "./facemesh";
|
|
9
8
|
import { Event } from "./event";
|
|
10
9
|
import { ImageTracker } from "./imagetracker";
|
|
10
|
+
import { zappar } from "./gen/zappar-bridge";
|
|
11
|
+
import { CameraFrameData } from "./camera-frame-data";
|
|
11
12
|
export declare class Pipeline {
|
|
12
13
|
private _client;
|
|
13
14
|
private _impl;
|
|
@@ -27,12 +28,17 @@ export declare class Pipeline {
|
|
|
27
28
|
private _sequenceRecorder;
|
|
28
29
|
private _sequenceRecordDeviceAttitudeMatrices;
|
|
29
30
|
private _sequenceRecorderFirstCameraToken;
|
|
31
|
+
private _cameraFrameDataPromises;
|
|
32
|
+
private _cameraFrameDataResolves;
|
|
33
|
+
private _cameraFrameDataRejects;
|
|
34
|
+
private _cameraFrameDataEnabled;
|
|
30
35
|
onGLContextReset: Event;
|
|
31
|
-
static create(client:
|
|
36
|
+
static create(client: zappar, mgr: MsgManager): zappar_pipeline_t;
|
|
32
37
|
static get(p: zappar_pipeline_t): Pipeline | undefined;
|
|
33
38
|
private constructor();
|
|
34
39
|
frameUpdate(client: zappar_client): void;
|
|
35
40
|
cleanOldFrames(): void;
|
|
41
|
+
cameraFrameDataRawResult(msg: CameraDataRawS2C): void;
|
|
36
42
|
cameraTokenReturn(msg: CameraFrameReturnS2C): void;
|
|
37
43
|
sequenceRecordStart(expectedFrames: number): void;
|
|
38
44
|
sequenceRecordStop(): void;
|
|
@@ -40,6 +46,8 @@ export declare class Pipeline {
|
|
|
40
46
|
sequenceRecordClear(): void;
|
|
41
47
|
sequenceRecordDeviceAttitudeMatrices(v: boolean): void;
|
|
42
48
|
getVideoTexture(): WebGLTexture | undefined;
|
|
49
|
+
getCameraFrameDataRaw(): Promise<CameraFrameData | undefined>;
|
|
50
|
+
setCameraFrameDataRawEnabled(e: boolean): void;
|
|
43
51
|
destroy(): void;
|
|
44
52
|
getCurrentCameraInfo(): CameraFrameInfo | undefined;
|
|
45
53
|
cameraFrameDrawGL(screenWidth: number, screenHeight: number, mirror?: boolean): void;
|
package/lib/pipeline.js
CHANGED
|
@@ -24,6 +24,10 @@ export class Pipeline {
|
|
|
24
24
|
this.cameraPixelArrays = [];
|
|
25
25
|
this._sequenceRecordDeviceAttitudeMatrices = true;
|
|
26
26
|
this._sequenceRecorderFirstCameraToken = 0;
|
|
27
|
+
this._cameraFrameDataPromises = new Map();
|
|
28
|
+
this._cameraFrameDataResolves = new Map();
|
|
29
|
+
this._cameraFrameDataRejects = new Map();
|
|
30
|
+
this._cameraFrameDataEnabled = false;
|
|
27
31
|
this.onGLContextReset = new Event();
|
|
28
32
|
}
|
|
29
33
|
static create(client, mgr) {
|
|
@@ -56,14 +60,34 @@ export class Pipeline {
|
|
|
56
60
|
if (t[1].texture)
|
|
57
61
|
this.videoTextures.push(t[1].texture);
|
|
58
62
|
(_b = (_a = t[1].frame) === null || _a === void 0 ? void 0 : _a.close) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
63
|
+
if (t[1].data) {
|
|
64
|
+
this.cameraPixelArrays.push(t[1].data);
|
|
65
|
+
t[1].data = undefined;
|
|
66
|
+
}
|
|
59
67
|
this.cameraTokens.delete(t[0]);
|
|
60
68
|
}
|
|
61
69
|
}
|
|
62
70
|
}
|
|
71
|
+
cameraFrameDataRawResult(msg) {
|
|
72
|
+
var _a, _b;
|
|
73
|
+
let info = this.cameraTokens.get(msg.token);
|
|
74
|
+
if (!info)
|
|
75
|
+
return;
|
|
76
|
+
if (msg.data === null) {
|
|
77
|
+
(_a = this._cameraFrameDataRejects.get(info)) === null || _a === void 0 ? void 0 : _a(new Error('Raw camera data not available'));
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
info.data = msg.data.data;
|
|
81
|
+
(_b = this._cameraFrameDataResolves.get(info)) === null || _b === void 0 ? void 0 : _b(msg.data);
|
|
82
|
+
}
|
|
83
|
+
this._cameraFrameDataRejects.delete(info);
|
|
84
|
+
this._cameraFrameDataResolves.delete(info);
|
|
85
|
+
this._cameraFrameDataPromises.delete(info);
|
|
86
|
+
}
|
|
63
87
|
cameraTokenReturn(msg) {
|
|
88
|
+
let info = this.cameraTokens.get(msg.token);
|
|
64
89
|
if (this._sequenceRecorder && this._sequenceRecordDeviceAttitudeMatrices
|
|
65
90
|
&& msg.token >= this._sequenceRecorderFirstCameraToken) {
|
|
66
|
-
let info = this.cameraTokens.get(msg.token);
|
|
67
91
|
if (info) {
|
|
68
92
|
if (msg.att)
|
|
69
93
|
this._sequenceRecorder.appendAttitudeMatrix(msg.att);
|
|
@@ -71,7 +95,20 @@ export class Pipeline {
|
|
|
71
95
|
this._sequenceRecorder.appendCameraFrame(info);
|
|
72
96
|
}
|
|
73
97
|
}
|
|
74
|
-
|
|
98
|
+
if (info && !info.data && msg.d) {
|
|
99
|
+
info.data = msg.d;
|
|
100
|
+
const rawRequestResolve = this._cameraFrameDataResolves.get(info);
|
|
101
|
+
if (rawRequestResolve) {
|
|
102
|
+
rawRequestResolve({
|
|
103
|
+
data: info.data,
|
|
104
|
+
width: info.dataWidth,
|
|
105
|
+
height: info.dataHeight,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
this._cameraFrameDataRejects.delete(info);
|
|
109
|
+
this._cameraFrameDataResolves.delete(info);
|
|
110
|
+
this._cameraFrameDataPromises.delete(info);
|
|
111
|
+
}
|
|
75
112
|
this.tokensInFlight--;
|
|
76
113
|
}
|
|
77
114
|
sequenceRecordStart(expectedFrames) {
|
|
@@ -97,6 +134,37 @@ export class Pipeline {
|
|
|
97
134
|
getVideoTexture() {
|
|
98
135
|
return this.videoTextures.pop();
|
|
99
136
|
}
|
|
137
|
+
getCameraFrameDataRaw() {
|
|
138
|
+
if (!this._cameraFrameDataEnabled)
|
|
139
|
+
throw new Error('Raw camera frame data is not enabled.');
|
|
140
|
+
const info = this.getCurrentCameraInfo();
|
|
141
|
+
if (!info)
|
|
142
|
+
return Promise.resolve(undefined);
|
|
143
|
+
if (info.data)
|
|
144
|
+
return Promise.resolve({ data: info.data.slice(0), width: info.dataWidth, height: info.dataHeight });
|
|
145
|
+
let existing = this._cameraFrameDataPromises.get(info);
|
|
146
|
+
if (!existing) {
|
|
147
|
+
existing = new Promise((resolve, reject) => {
|
|
148
|
+
if (typeof info.remoteToken !== 'undefined') {
|
|
149
|
+
const msg = {
|
|
150
|
+
t: "rawrequest",
|
|
151
|
+
token: info.remoteToken,
|
|
152
|
+
p: this._impl,
|
|
153
|
+
};
|
|
154
|
+
this._mgr.postOutgoingMessage(msg, []);
|
|
155
|
+
}
|
|
156
|
+
this._cameraFrameDataResolves.set(info, resolve);
|
|
157
|
+
this._cameraFrameDataRejects.set(info, reject);
|
|
158
|
+
});
|
|
159
|
+
this._cameraFrameDataPromises.set(info, existing);
|
|
160
|
+
}
|
|
161
|
+
return existing;
|
|
162
|
+
}
|
|
163
|
+
setCameraFrameDataRawEnabled(e) {
|
|
164
|
+
this._cameraFrameDataEnabled = e;
|
|
165
|
+
const msg = { t: 'rawenabled', v: e };
|
|
166
|
+
this._mgr.postOutgoingMessage(msg, []);
|
|
167
|
+
}
|
|
100
168
|
destroy() {
|
|
101
169
|
this._client.pipeline_destroy(this._impl);
|
|
102
170
|
byId.delete(this._impl);
|
|
@@ -226,7 +294,8 @@ export class Pipeline {
|
|
|
226
294
|
uvTransform: msg.uvTransform,
|
|
227
295
|
cameraModel: msg.cameraModel,
|
|
228
296
|
cameraToDevice: msg.cameraToDevice,
|
|
229
|
-
cameraSource
|
|
297
|
+
cameraSource,
|
|
298
|
+
remoteToken: msg.token,
|
|
230
299
|
});
|
|
231
300
|
this.cleanOldFrames();
|
|
232
301
|
}
|
package/lib/source.d.ts
CHANGED
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.2";
|
package/lib/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "3.0.1-alpha.
|
|
1
|
+
export const VERSION = "3.0.1-alpha.2";
|
package/lib/worker-server.js
CHANGED
|
@@ -19,6 +19,8 @@ import { getWorkerMessageAPI } from "./worker-messages";
|
|
|
19
19
|
export let messageManager = new MsgManager();
|
|
20
20
|
let workerMessageChannel;
|
|
21
21
|
let latestCameraToScreenRotation = 0;
|
|
22
|
+
let rawDataAccessEnabled = false;
|
|
23
|
+
const rawCameraFrameBuffersByPipeline = new Map();
|
|
22
24
|
export function launchWorkerServer(wasmUrl, module) {
|
|
23
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
24
26
|
let mod = ZNM.default({
|
|
@@ -45,7 +47,7 @@ export function launchWorkerServer(wasmUrl, module) {
|
|
|
45
47
|
});
|
|
46
48
|
messageManager.postOutgoingMessage("loaded", []);
|
|
47
49
|
messageManager.onIncomingMessage.bind((msg) => {
|
|
48
|
-
var _a;
|
|
50
|
+
var _a, _b, _c;
|
|
49
51
|
switch (msg.t) {
|
|
50
52
|
case "zappar":
|
|
51
53
|
server.processBuffer(msg.d);
|
|
@@ -75,6 +77,23 @@ export function launchWorkerServer(wasmUrl, module) {
|
|
|
75
77
|
messageManager.postOutgoingMessage(ret, [msgt.d]);
|
|
76
78
|
break;
|
|
77
79
|
}
|
|
80
|
+
case "rawenabled": {
|
|
81
|
+
const msgt = msg;
|
|
82
|
+
rawDataAccessEnabled = msgt.v;
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
case "rawrequest": {
|
|
86
|
+
const msgt = msg;
|
|
87
|
+
const buffers = rawCameraFrameBuffersByPipeline.get(msgt.p);
|
|
88
|
+
const ret = {
|
|
89
|
+
t: "raw",
|
|
90
|
+
token: msgt.token,
|
|
91
|
+
p: msgt.p,
|
|
92
|
+
data: buffers ? (_c = (_b = buffers.ready.find(entry => entry.token === msgt.token)) === null || _b === void 0 ? void 0 : _b.data) !== null && _c !== void 0 ? _c : null : null,
|
|
93
|
+
};
|
|
94
|
+
messageManager.postOutgoingMessage(ret, []);
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
78
97
|
case "streamC2S": {
|
|
79
98
|
let msgt = msg;
|
|
80
99
|
consumeStream(mod, r, msgt.s, msgt.p, msgt.userFacing, server, msgt.source, workerMessageAPI).then(() => {
|
|
@@ -243,8 +262,8 @@ function consumeReader(mod, r, reader, p, userFacing, server, source, workerMess
|
|
|
243
262
|
t: "videoFrameS2C",
|
|
244
263
|
userFacing,
|
|
245
264
|
uvTransform,
|
|
246
|
-
w: dataWidth,
|
|
247
|
-
h: dataHeight,
|
|
265
|
+
w: profile.dataWidth,
|
|
266
|
+
h: profile.dataHeight,
|
|
248
267
|
cameraToDevice: cameraToDeviceTransform,
|
|
249
268
|
cameraModel,
|
|
250
269
|
source
|
|
@@ -263,6 +282,32 @@ function consumeReader(mod, r, reader, p, userFacing, server, source, workerMess
|
|
|
263
282
|
// (mod as any).ccall('what_to_stderr', 'number', ['number'], [err]);
|
|
264
283
|
}
|
|
265
284
|
r.pipeline_frame_update(pipeline);
|
|
285
|
+
if (rawDataAccessEnabled) {
|
|
286
|
+
let buffers = rawCameraFrameBuffersByPipeline.get(p);
|
|
287
|
+
if (!buffers) {
|
|
288
|
+
buffers = { available: [], ready: [] };
|
|
289
|
+
rawCameraFrameBuffersByPipeline.set(p, buffers);
|
|
290
|
+
}
|
|
291
|
+
if (buffers.ready.length > 4) {
|
|
292
|
+
const removed = buffers.ready.splice(0, 1);
|
|
293
|
+
for (const entry of removed)
|
|
294
|
+
buffers.available.push(new Uint8Array(entry.data.data));
|
|
295
|
+
}
|
|
296
|
+
const size = r.pipeline_camera_frame_data_raw_size(pipeline);
|
|
297
|
+
let buffer;
|
|
298
|
+
while (!buffer || buffer.byteLength < size) {
|
|
299
|
+
if (buffers.available.length < 1)
|
|
300
|
+
buffers.available.push(new Uint8Array(size));
|
|
301
|
+
buffer = buffers.available.pop();
|
|
302
|
+
}
|
|
303
|
+
const dataPointer = r.pipeline_camera_frame_data_raw(pipeline);
|
|
304
|
+
buffer.set(mod.HEAPU8.subarray(dataPointer, dataPointer + size));
|
|
305
|
+
buffers.ready.push({ token, data: {
|
|
306
|
+
data: buffer,
|
|
307
|
+
width: r.pipeline_camera_frame_data_raw_width(p),
|
|
308
|
+
height: r.pipeline_camera_frame_data_raw_height(p),
|
|
309
|
+
} });
|
|
310
|
+
}
|
|
266
311
|
server.exploreState();
|
|
267
312
|
}
|
|
268
313
|
frame.close();
|
package/lib/workerinterface.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="dom-webcodecs" />
|
|
2
|
+
import { CameraFrameData } from "./camera-frame-data";
|
|
2
3
|
import { zappar_camera_source_t, zappar_pipeline_t } from "./gen/zappar-native";
|
|
3
4
|
export interface CameraFrameC2S {
|
|
4
5
|
t: "cameraFrameC2S";
|
|
@@ -83,3 +84,18 @@ export interface AttitudeMatrixC2S {
|
|
|
83
84
|
p: zappar_pipeline_t;
|
|
84
85
|
m: Float32Array;
|
|
85
86
|
}
|
|
87
|
+
export interface CameraDataRawEnabledC2S {
|
|
88
|
+
t: "rawenabled";
|
|
89
|
+
v: boolean;
|
|
90
|
+
}
|
|
91
|
+
export interface CameraDataRawRequestC2S {
|
|
92
|
+
t: "rawrequest";
|
|
93
|
+
p: zappar_pipeline_t;
|
|
94
|
+
token: number;
|
|
95
|
+
}
|
|
96
|
+
export interface CameraDataRawS2C {
|
|
97
|
+
t: "raw";
|
|
98
|
+
token: number;
|
|
99
|
+
p: zappar_pipeline_t;
|
|
100
|
+
data: CameraFrameData | null;
|
|
101
|
+
}
|