@web-ar-studio/webar-engine-sdk 1.0.7 → 1.0.8
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/LICENSE +28 -28
- package/README.md +10 -2
- package/dist/index.d.ts +261 -261
- package/package.json +32 -32
package/LICENSE
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
BSD 3-Clause License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2023, WebAR Studio
|
|
4
|
-
|
|
5
|
-
Redistribution and use in source and binary forms, with or without
|
|
6
|
-
modification, are permitted provided that the following conditions are met:
|
|
7
|
-
|
|
8
|
-
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
-
list of conditions and the following disclaimer.
|
|
10
|
-
|
|
11
|
-
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
-
this list of conditions and the following disclaimer in the documentation
|
|
13
|
-
and/or other materials provided with the distribution.
|
|
14
|
-
|
|
15
|
-
3. Neither the name of the copyright holder nor the names of its
|
|
16
|
-
contributors may be used to endorse or promote products derived from
|
|
17
|
-
this software without specific prior written permission.
|
|
18
|
-
|
|
19
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
-
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
23
|
-
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
-
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
-
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
-
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
|
-
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023, WebAR Studio
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
16
|
+
contributors may be used to endorse or promote products derived from
|
|
17
|
+
this software without specific prior written permission.
|
|
18
|
+
|
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
23
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
CHANGED
|
@@ -1,2 +1,10 @@
|
|
|
1
|
-
# webar-engine-sdk
|
|
2
|
-
WAS CV Lib - SDK of the WebAR CV Lib
|
|
1
|
+
# webar-engine-sdk
|
|
2
|
+
WAS CV Lib - SDK of the WebAR CV Lib
|
|
3
|
+
|
|
4
|
+
Installation instructions for the package and sample projects featuring image, QR, face, and AR 360 tracking can be found at https://github.com/WebAR-Studio/webar-sdk-samples
|
|
5
|
+
|
|
6
|
+
You can use our library for free for non-commercial and educational purposes. For commercial use, you can purchase any tariff from https://web-ar.studio/en/pricing/. There are no limitations on the number of project scans, and the library itself is continuously improved.
|
|
7
|
+
|
|
8
|
+
In the repository with examples, you can find a key for local project launches. To obtain a key for public builds, please contact us at https://discord.gg/XQpe5P48 or https://t.me/was_team.
|
|
9
|
+
|
|
10
|
+
Our library is fully typed, so after installation, you can easily see all possible types and arguments.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,261 +1,261 @@
|
|
|
1
|
-
declare const PROJECT_MODE_QR = "QR";
|
|
2
|
-
declare const PROJECT_MODE_IMAGE = "IMAGE";
|
|
3
|
-
declare const PROJECT_MODE_SLAM_3DOF = "SLAM_3DOF";
|
|
4
|
-
declare const PROJECT_MODE_FACE = "FACE";
|
|
5
|
-
declare const PROJECT_MODE_MIX = "MIX";
|
|
6
|
-
declare const TRIGGER_MODE_QR = "QR";
|
|
7
|
-
declare const TRIGGER_MODE_IMAGE = "IMAGE";
|
|
8
|
-
declare const TRIGGER_MODE_FACE = "FACE";
|
|
9
|
-
declare const EVENT_DETECTED = "detected";
|
|
10
|
-
declare const EVENT_LOST = "lost";
|
|
11
|
-
declare const EVENT_POSE = "pose";
|
|
12
|
-
declare const EVENT_PROCESS = "process";
|
|
13
|
-
declare const EVENT_RESIZE = "resize";
|
|
14
|
-
declare const EVENT_DEVICE_ORIENTATION = "deviceorientation";
|
|
15
|
-
declare const EVENT_SCREEN_ORIENTATION = "change";
|
|
16
|
-
declare const EVENT_VISIBILITY = "visibilitychange";
|
|
17
|
-
declare const EVENT_FRAME = "frame";
|
|
18
|
-
declare const DATA_ERROR = "DataError";
|
|
19
|
-
declare const EVENT_ERROR = "EventError";
|
|
20
|
-
declare const GL_ERROR = "GlError";
|
|
21
|
-
declare const WORKER_ERROR = "WorkerError";
|
|
22
|
-
declare const HTML_ERROR = "HTMLError";
|
|
23
|
-
declare const DEVICE_ERROR = "DeviceError";
|
|
24
|
-
declare const VIDEO_ERROR = "VideoError";
|
|
25
|
-
declare const ANCHOR_TYPE_BOTTOM_LEFT = "bottomLeft";
|
|
26
|
-
declare const ANCHOR_TYPE_BOTTOM_RIGHT = "bottomRight";
|
|
27
|
-
declare const ANCHOR_TYPE_TOP_LEFT = "topLeft";
|
|
28
|
-
declare const ANCHOR_TYPE_TOP_RIGHT = "topRight";
|
|
29
|
-
declare const ANCHOR_TYPE_CENTER = "center";
|
|
30
|
-
declare const ANCHOR_TYPE_ORIGIN = "origin";
|
|
31
|
-
declare const ANCHOR_TYPE_LEFT_EYEBROW = 283;
|
|
32
|
-
declare const ANCHOR_TYPE_RIGHT_EYEBROW = 53;
|
|
33
|
-
declare const ANCHOR_TYPE_LEFT_EAR = 356;
|
|
34
|
-
declare const ANCHOR_TYPE_RIGHT_EAR = 127;
|
|
35
|
-
declare const ANCHOR_TYPE_LEFT_EYE = 374;
|
|
36
|
-
declare const ANCHOR_TYPE_RIGHT_EYE = 145;
|
|
37
|
-
declare const ANCHOR_TYPE_NOSE_BRIDGE = 6;
|
|
38
|
-
declare const ANCHOR_TYPE_NOSE_TIP = 4;
|
|
39
|
-
declare const ANCHOR_TYPE_NOSE_BASE = 2;
|
|
40
|
-
declare const ANCHOR_TYPE_BOTTOM_LIP = 14;
|
|
41
|
-
declare const ANCHOR_TYPE_CHIN = 199;
|
|
42
|
-
|
|
43
|
-
type TTriggerMode = typeof TRIGGER_MODE_QR | typeof TRIGGER_MODE_IMAGE | typeof TRIGGER_MODE_FACE;
|
|
44
|
-
|
|
45
|
-
type TTrigger = {
|
|
46
|
-
id: number;
|
|
47
|
-
mode: TTriggerMode;
|
|
48
|
-
} & ({
|
|
49
|
-
mode: typeof TRIGGER_MODE_FACE;
|
|
50
|
-
source: null;
|
|
51
|
-
} | {
|
|
52
|
-
mode: Exclude<TTriggerMode, typeof TRIGGER_MODE_FACE>;
|
|
53
|
-
source: string;
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
type TProjectMode = typeof PROJECT_MODE_QR | typeof PROJECT_MODE_IMAGE | typeof PROJECT_MODE_SLAM_3DOF | typeof PROJECT_MODE_FACE | typeof PROJECT_MODE_MIX;
|
|
57
|
-
|
|
58
|
-
type TAnchorType = typeof ANCHOR_TYPE_BOTTOM_LEFT | typeof ANCHOR_TYPE_BOTTOM_RIGHT | typeof ANCHOR_TYPE_TOP_LEFT | typeof ANCHOR_TYPE_TOP_RIGHT | typeof ANCHOR_TYPE_CENTER;
|
|
59
|
-
|
|
60
|
-
type TAnchorFaceType = typeof ANCHOR_TYPE_ORIGIN | typeof ANCHOR_TYPE_LEFT_EYEBROW | typeof ANCHOR_TYPE_RIGHT_EYEBROW | typeof ANCHOR_TYPE_LEFT_EAR | typeof ANCHOR_TYPE_RIGHT_EAR | typeof ANCHOR_TYPE_LEFT_EYE | typeof ANCHOR_TYPE_RIGHT_EYE | typeof ANCHOR_TYPE_NOSE_BRIDGE | typeof ANCHOR_TYPE_NOSE_TIP | typeof ANCHOR_TYPE_NOSE_BASE | typeof ANCHOR_TYPE_BOTTOM_LIP | typeof ANCHOR_TYPE_CHIN;
|
|
61
|
-
|
|
62
|
-
type TConfigData = {
|
|
63
|
-
apiKey: string;
|
|
64
|
-
mode: TProjectMode;
|
|
65
|
-
container: Element;
|
|
66
|
-
} & ({
|
|
67
|
-
mode: typeof PROJECT_MODE_SLAM_3DOF;
|
|
68
|
-
fov?: never;
|
|
69
|
-
near?: never;
|
|
70
|
-
far?: never;
|
|
71
|
-
triggers?: never;
|
|
72
|
-
isMultiTracking?: never;
|
|
73
|
-
anchor?: never;
|
|
74
|
-
} | {
|
|
75
|
-
mode: typeof PROJECT_MODE_FACE;
|
|
76
|
-
fov: number;
|
|
77
|
-
near: number;
|
|
78
|
-
far: number;
|
|
79
|
-
triggers: TTrigger[];
|
|
80
|
-
isMultiTracking?: never;
|
|
81
|
-
anchor?: TAnchorFaceType;
|
|
82
|
-
} | {
|
|
83
|
-
mode: Exclude<TProjectMode, typeof PROJECT_MODE_SLAM_3DOF | typeof PROJECT_MODE_FACE>;
|
|
84
|
-
fov: number;
|
|
85
|
-
near?: never;
|
|
86
|
-
far?: never;
|
|
87
|
-
triggers: TTrigger[];
|
|
88
|
-
isMultiTracking: boolean;
|
|
89
|
-
anchor: TAnchorType;
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
type TEventWASType = typeof EVENT_DETECTED | typeof EVENT_LOST | typeof EVENT_POSE | typeof EVENT_PROCESS | typeof EVENT_RESIZE | typeof EVENT_DEVICE_ORIENTATION | typeof EVENT_SCREEN_ORIENTATION | typeof EVENT_VISIBILITY | typeof EVENT_FRAME;
|
|
93
|
-
|
|
94
|
-
type TVector = {
|
|
95
|
-
x: number;
|
|
96
|
-
y: number;
|
|
97
|
-
z: number;
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
type TQuaternion = {
|
|
101
|
-
x: number;
|
|
102
|
-
y: number;
|
|
103
|
-
z: number;
|
|
104
|
-
w: number;
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
type TEventDetectedData = {
|
|
108
|
-
triggerId: number;
|
|
109
|
-
positionVector: TVector;
|
|
110
|
-
rotationQuaternion: TQuaternion;
|
|
111
|
-
scaleVector: TVector;
|
|
112
|
-
landmarksData?: TVector[];
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
type TEventLostData = {
|
|
116
|
-
triggerId: number;
|
|
117
|
-
positionVector: TVector;
|
|
118
|
-
rotationQuaternion: TQuaternion;
|
|
119
|
-
scaleVector: TVector;
|
|
120
|
-
landmarksData?: TVector[];
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
type TEventPoseData = {
|
|
124
|
-
triggerId: number;
|
|
125
|
-
positionVector: TVector;
|
|
126
|
-
rotationQuaternion: TQuaternion;
|
|
127
|
-
scaleVector: TVector;
|
|
128
|
-
landmarksData?: TVector[];
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
type TEventWASCallBack = {
|
|
132
|
-
(detectedData: TEventDetectedData[]): void;
|
|
133
|
-
(lostData: TEventLostData[]): void;
|
|
134
|
-
(poseData: TEventPoseData[]): void;
|
|
135
|
-
(isProcess: boolean): void;
|
|
136
|
-
(event: UIEvent): void;
|
|
137
|
-
(event: DeviceOrientationEvent): void;
|
|
138
|
-
(angle: number): void;
|
|
139
|
-
(isVisible: boolean): void;
|
|
140
|
-
(deltaTime: number): void;
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
type TEventType = typeof EVENT_DETECTED | typeof EVENT_LOST | typeof EVENT_POSE | typeof EVENT_PROCESS | typeof EVENT_RESIZE | typeof EVENT_DEVICE_ORIENTATION | typeof EVENT_SCREEN_ORIENTATION | typeof EVENT_VISIBILITY | typeof EVENT_FRAME;
|
|
144
|
-
|
|
145
|
-
type TViewportSizes = {
|
|
146
|
-
width: number;
|
|
147
|
-
height: number;
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
type TWAS = {
|
|
151
|
-
canvas: HTMLCanvasElement;
|
|
152
|
-
context: WebGL2RenderingContext | WebGLRenderingContext | null;
|
|
153
|
-
videoCanvas: HTMLCanvasElement;
|
|
154
|
-
viewportSizes: TViewportSizes;
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
type TTriggerSize = {
|
|
158
|
-
id: number;
|
|
159
|
-
width: number;
|
|
160
|
-
height: number;
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
interface IWAS {
|
|
164
|
-
init(configData: TConfigData): Promise<TWAS>;
|
|
165
|
-
on(type: TEventWASType, callBack: TEventWASCallBack): Promise<void>;
|
|
166
|
-
un(type: TEventType): Promise<void>;
|
|
167
|
-
dispose(): Promise<void>;
|
|
168
|
-
setMediaStream(): Promise<void>;
|
|
169
|
-
getTriggerSize(triggerId: number): TTriggerSize | undefined;
|
|
170
|
-
getTriggerScale(triggerId: number): TVector | undefined;
|
|
171
|
-
getViewportSizes(): TViewportSizes;
|
|
172
|
-
getFaceMeshTriangulation(): Uint16Array;
|
|
173
|
-
getFaceMeshTriangulationFillMouth(): Uint16Array;
|
|
174
|
-
getFaceMeshTriangulationFillEyes(): Uint16Array;
|
|
175
|
-
getFaceMeshTriangulationFill(): Uint16Array;
|
|
176
|
-
getFaceMeshUv(): Float32Array;
|
|
177
|
-
getFaceMeshPosition(): Float32Array;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
declare class WAS implements IWAS {
|
|
181
|
-
private configData;
|
|
182
|
-
private video;
|
|
183
|
-
private canvas3D;
|
|
184
|
-
private canvasGrayscale;
|
|
185
|
-
private canvasGrayscale2D;
|
|
186
|
-
private canvasVideo;
|
|
187
|
-
private canvas3DContext;
|
|
188
|
-
private canvasGrayscaleContext;
|
|
189
|
-
private canvasGrayscale2DContext;
|
|
190
|
-
private canvasVideoContext;
|
|
191
|
-
private isSaveFrame;
|
|
192
|
-
private videoWidth;
|
|
193
|
-
private videoHeight;
|
|
194
|
-
private containerWidth;
|
|
195
|
-
private containerHeight;
|
|
196
|
-
private isMessageSent;
|
|
197
|
-
private isMessageSentSetConfig;
|
|
198
|
-
private isNeedToSetConfig;
|
|
199
|
-
private isProcess;
|
|
200
|
-
private countTriggers;
|
|
201
|
-
private triggerSizes;
|
|
202
|
-
private triggerScales;
|
|
203
|
-
private checkPerformance;
|
|
204
|
-
private checkPose;
|
|
205
|
-
private faceLandmarker;
|
|
206
|
-
private faceLandmarkerTime;
|
|
207
|
-
private faceData;
|
|
208
|
-
private readonly fov;
|
|
209
|
-
private readonly near;
|
|
210
|
-
private readonly far;
|
|
211
|
-
private readonly browserManager;
|
|
212
|
-
private readonly eventsManager;
|
|
213
|
-
private readonly dataManager;
|
|
214
|
-
private readonly glManager;
|
|
215
|
-
private readonly workerManager;
|
|
216
|
-
constructor();
|
|
217
|
-
init(configData: TConfigData): Promise<TWAS>;
|
|
218
|
-
on(type: typeof EVENT_DETECTED, callBack: (detectedData: TEventDetectedData[]) => void): Promise<void>;
|
|
219
|
-
on(type: typeof EVENT_LOST, callBack: (lostData: TEventLostData[]) => void): Promise<void>;
|
|
220
|
-
on(type: typeof EVENT_POSE, callBack: (poseData: TEventPoseData[]) => void): Promise<void>;
|
|
221
|
-
on(type: typeof EVENT_PROCESS, callBack: (isProcess: boolean) => void): Promise<void>;
|
|
222
|
-
on(type: typeof EVENT_RESIZE, callBack: (event: UIEvent) => void): Promise<void>;
|
|
223
|
-
on(type: typeof EVENT_DEVICE_ORIENTATION, callBack: (event: DeviceOrientationEvent) => void): Promise<void>;
|
|
224
|
-
on(type: typeof EVENT_SCREEN_ORIENTATION, callBack: (angle: number) => void): Promise<void>;
|
|
225
|
-
on(type: typeof EVENT_VISIBILITY, callBack: (isVisible: boolean) => void): Promise<void>;
|
|
226
|
-
on(type: typeof EVENT_FRAME, callBack: (deltaTime: number) => void): Promise<void>;
|
|
227
|
-
un(type: TEventType): Promise<void>;
|
|
228
|
-
dispose(): Promise<void>;
|
|
229
|
-
private initVideo;
|
|
230
|
-
private initCanvas;
|
|
231
|
-
private initContext;
|
|
232
|
-
setMediaStream(): Promise<void>;
|
|
233
|
-
private updateSizes;
|
|
234
|
-
private setVideoWidth;
|
|
235
|
-
private setVideoHeight;
|
|
236
|
-
private getVideoWidth;
|
|
237
|
-
private getVideoHeight;
|
|
238
|
-
private setContainerWidth;
|
|
239
|
-
private setContainerHeight;
|
|
240
|
-
private getContainerWidth;
|
|
241
|
-
private getContainerHeight;
|
|
242
|
-
private restartMediaStream;
|
|
243
|
-
private setConfig;
|
|
244
|
-
private setTriggers;
|
|
245
|
-
private loadImage;
|
|
246
|
-
private initFaceLandmarker;
|
|
247
|
-
private faceLandmarkerProcess;
|
|
248
|
-
private process;
|
|
249
|
-
private drawVideo;
|
|
250
|
-
getTriggerSize(triggerId: number): TTriggerSize | undefined;
|
|
251
|
-
getTriggerScale(triggerId: number): TVector | undefined;
|
|
252
|
-
getViewportSizes(): TViewportSizes;
|
|
253
|
-
getFaceMeshTriangulation(): Uint16Array;
|
|
254
|
-
getFaceMeshTriangulationFillMouth(): Uint16Array;
|
|
255
|
-
getFaceMeshTriangulationFillEyes(): Uint16Array;
|
|
256
|
-
getFaceMeshTriangulationFill(): Uint16Array;
|
|
257
|
-
getFaceMeshUv(): Float32Array;
|
|
258
|
-
getFaceMeshPosition(): Float32Array;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
export { ANCHOR_TYPE_BOTTOM_LEFT, ANCHOR_TYPE_BOTTOM_LIP, ANCHOR_TYPE_BOTTOM_RIGHT, ANCHOR_TYPE_CENTER, ANCHOR_TYPE_CHIN, ANCHOR_TYPE_LEFT_EAR, ANCHOR_TYPE_LEFT_EYE, ANCHOR_TYPE_LEFT_EYEBROW, ANCHOR_TYPE_NOSE_BASE, ANCHOR_TYPE_NOSE_BRIDGE, ANCHOR_TYPE_NOSE_TIP, ANCHOR_TYPE_ORIGIN, ANCHOR_TYPE_RIGHT_EAR, ANCHOR_TYPE_RIGHT_EYE, ANCHOR_TYPE_RIGHT_EYEBROW, ANCHOR_TYPE_TOP_LEFT, ANCHOR_TYPE_TOP_RIGHT, DATA_ERROR, DEVICE_ERROR, EVENT_DETECTED, EVENT_DEVICE_ORIENTATION, EVENT_ERROR, EVENT_FRAME, EVENT_LOST, EVENT_POSE, EVENT_PROCESS, EVENT_RESIZE, EVENT_SCREEN_ORIENTATION, EVENT_VISIBILITY, GL_ERROR, HTML_ERROR, PROJECT_MODE_FACE, PROJECT_MODE_IMAGE, PROJECT_MODE_MIX, PROJECT_MODE_QR, PROJECT_MODE_SLAM_3DOF, type TEventDetectedData, type TEventLostData, type TEventPoseData, TRIGGER_MODE_FACE, TRIGGER_MODE_IMAGE, TRIGGER_MODE_QR, type TTriggerSize, type TViewportSizes, VIDEO_ERROR, WORKER_ERROR, WAS as default };
|
|
1
|
+
declare const PROJECT_MODE_QR = "QR";
|
|
2
|
+
declare const PROJECT_MODE_IMAGE = "IMAGE";
|
|
3
|
+
declare const PROJECT_MODE_SLAM_3DOF = "SLAM_3DOF";
|
|
4
|
+
declare const PROJECT_MODE_FACE = "FACE";
|
|
5
|
+
declare const PROJECT_MODE_MIX = "MIX";
|
|
6
|
+
declare const TRIGGER_MODE_QR = "QR";
|
|
7
|
+
declare const TRIGGER_MODE_IMAGE = "IMAGE";
|
|
8
|
+
declare const TRIGGER_MODE_FACE = "FACE";
|
|
9
|
+
declare const EVENT_DETECTED = "detected";
|
|
10
|
+
declare const EVENT_LOST = "lost";
|
|
11
|
+
declare const EVENT_POSE = "pose";
|
|
12
|
+
declare const EVENT_PROCESS = "process";
|
|
13
|
+
declare const EVENT_RESIZE = "resize";
|
|
14
|
+
declare const EVENT_DEVICE_ORIENTATION = "deviceorientation";
|
|
15
|
+
declare const EVENT_SCREEN_ORIENTATION = "change";
|
|
16
|
+
declare const EVENT_VISIBILITY = "visibilitychange";
|
|
17
|
+
declare const EVENT_FRAME = "frame";
|
|
18
|
+
declare const DATA_ERROR = "DataError";
|
|
19
|
+
declare const EVENT_ERROR = "EventError";
|
|
20
|
+
declare const GL_ERROR = "GlError";
|
|
21
|
+
declare const WORKER_ERROR = "WorkerError";
|
|
22
|
+
declare const HTML_ERROR = "HTMLError";
|
|
23
|
+
declare const DEVICE_ERROR = "DeviceError";
|
|
24
|
+
declare const VIDEO_ERROR = "VideoError";
|
|
25
|
+
declare const ANCHOR_TYPE_BOTTOM_LEFT = "bottomLeft";
|
|
26
|
+
declare const ANCHOR_TYPE_BOTTOM_RIGHT = "bottomRight";
|
|
27
|
+
declare const ANCHOR_TYPE_TOP_LEFT = "topLeft";
|
|
28
|
+
declare const ANCHOR_TYPE_TOP_RIGHT = "topRight";
|
|
29
|
+
declare const ANCHOR_TYPE_CENTER = "center";
|
|
30
|
+
declare const ANCHOR_TYPE_ORIGIN = "origin";
|
|
31
|
+
declare const ANCHOR_TYPE_LEFT_EYEBROW = 283;
|
|
32
|
+
declare const ANCHOR_TYPE_RIGHT_EYEBROW = 53;
|
|
33
|
+
declare const ANCHOR_TYPE_LEFT_EAR = 356;
|
|
34
|
+
declare const ANCHOR_TYPE_RIGHT_EAR = 127;
|
|
35
|
+
declare const ANCHOR_TYPE_LEFT_EYE = 374;
|
|
36
|
+
declare const ANCHOR_TYPE_RIGHT_EYE = 145;
|
|
37
|
+
declare const ANCHOR_TYPE_NOSE_BRIDGE = 6;
|
|
38
|
+
declare const ANCHOR_TYPE_NOSE_TIP = 4;
|
|
39
|
+
declare const ANCHOR_TYPE_NOSE_BASE = 2;
|
|
40
|
+
declare const ANCHOR_TYPE_BOTTOM_LIP = 14;
|
|
41
|
+
declare const ANCHOR_TYPE_CHIN = 199;
|
|
42
|
+
|
|
43
|
+
type TTriggerMode = typeof TRIGGER_MODE_QR | typeof TRIGGER_MODE_IMAGE | typeof TRIGGER_MODE_FACE;
|
|
44
|
+
|
|
45
|
+
type TTrigger = {
|
|
46
|
+
id: number;
|
|
47
|
+
mode: TTriggerMode;
|
|
48
|
+
} & ({
|
|
49
|
+
mode: typeof TRIGGER_MODE_FACE;
|
|
50
|
+
source: null;
|
|
51
|
+
} | {
|
|
52
|
+
mode: Exclude<TTriggerMode, typeof TRIGGER_MODE_FACE>;
|
|
53
|
+
source: string;
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
type TProjectMode = typeof PROJECT_MODE_QR | typeof PROJECT_MODE_IMAGE | typeof PROJECT_MODE_SLAM_3DOF | typeof PROJECT_MODE_FACE | typeof PROJECT_MODE_MIX;
|
|
57
|
+
|
|
58
|
+
type TAnchorType = typeof ANCHOR_TYPE_BOTTOM_LEFT | typeof ANCHOR_TYPE_BOTTOM_RIGHT | typeof ANCHOR_TYPE_TOP_LEFT | typeof ANCHOR_TYPE_TOP_RIGHT | typeof ANCHOR_TYPE_CENTER;
|
|
59
|
+
|
|
60
|
+
type TAnchorFaceType = typeof ANCHOR_TYPE_ORIGIN | typeof ANCHOR_TYPE_LEFT_EYEBROW | typeof ANCHOR_TYPE_RIGHT_EYEBROW | typeof ANCHOR_TYPE_LEFT_EAR | typeof ANCHOR_TYPE_RIGHT_EAR | typeof ANCHOR_TYPE_LEFT_EYE | typeof ANCHOR_TYPE_RIGHT_EYE | typeof ANCHOR_TYPE_NOSE_BRIDGE | typeof ANCHOR_TYPE_NOSE_TIP | typeof ANCHOR_TYPE_NOSE_BASE | typeof ANCHOR_TYPE_BOTTOM_LIP | typeof ANCHOR_TYPE_CHIN;
|
|
61
|
+
|
|
62
|
+
type TConfigData = {
|
|
63
|
+
apiKey: string;
|
|
64
|
+
mode: TProjectMode;
|
|
65
|
+
container: Element;
|
|
66
|
+
} & ({
|
|
67
|
+
mode: typeof PROJECT_MODE_SLAM_3DOF;
|
|
68
|
+
fov?: never;
|
|
69
|
+
near?: never;
|
|
70
|
+
far?: never;
|
|
71
|
+
triggers?: never;
|
|
72
|
+
isMultiTracking?: never;
|
|
73
|
+
anchor?: never;
|
|
74
|
+
} | {
|
|
75
|
+
mode: typeof PROJECT_MODE_FACE;
|
|
76
|
+
fov: number;
|
|
77
|
+
near: number;
|
|
78
|
+
far: number;
|
|
79
|
+
triggers: TTrigger[];
|
|
80
|
+
isMultiTracking?: never;
|
|
81
|
+
anchor?: TAnchorFaceType;
|
|
82
|
+
} | {
|
|
83
|
+
mode: Exclude<TProjectMode, typeof PROJECT_MODE_SLAM_3DOF | typeof PROJECT_MODE_FACE>;
|
|
84
|
+
fov: number;
|
|
85
|
+
near?: never;
|
|
86
|
+
far?: never;
|
|
87
|
+
triggers: TTrigger[];
|
|
88
|
+
isMultiTracking: boolean;
|
|
89
|
+
anchor: TAnchorType;
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
type TEventWASType = typeof EVENT_DETECTED | typeof EVENT_LOST | typeof EVENT_POSE | typeof EVENT_PROCESS | typeof EVENT_RESIZE | typeof EVENT_DEVICE_ORIENTATION | typeof EVENT_SCREEN_ORIENTATION | typeof EVENT_VISIBILITY | typeof EVENT_FRAME;
|
|
93
|
+
|
|
94
|
+
type TVector = {
|
|
95
|
+
x: number;
|
|
96
|
+
y: number;
|
|
97
|
+
z: number;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
type TQuaternion = {
|
|
101
|
+
x: number;
|
|
102
|
+
y: number;
|
|
103
|
+
z: number;
|
|
104
|
+
w: number;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
type TEventDetectedData = {
|
|
108
|
+
triggerId: number;
|
|
109
|
+
positionVector: TVector;
|
|
110
|
+
rotationQuaternion: TQuaternion;
|
|
111
|
+
scaleVector: TVector;
|
|
112
|
+
landmarksData?: TVector[];
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
type TEventLostData = {
|
|
116
|
+
triggerId: number;
|
|
117
|
+
positionVector: TVector;
|
|
118
|
+
rotationQuaternion: TQuaternion;
|
|
119
|
+
scaleVector: TVector;
|
|
120
|
+
landmarksData?: TVector[];
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
type TEventPoseData = {
|
|
124
|
+
triggerId: number;
|
|
125
|
+
positionVector: TVector;
|
|
126
|
+
rotationQuaternion: TQuaternion;
|
|
127
|
+
scaleVector: TVector;
|
|
128
|
+
landmarksData?: TVector[];
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
type TEventWASCallBack = {
|
|
132
|
+
(detectedData: TEventDetectedData[]): void;
|
|
133
|
+
(lostData: TEventLostData[]): void;
|
|
134
|
+
(poseData: TEventPoseData[]): void;
|
|
135
|
+
(isProcess: boolean): void;
|
|
136
|
+
(event: UIEvent): void;
|
|
137
|
+
(event: DeviceOrientationEvent): void;
|
|
138
|
+
(angle: number): void;
|
|
139
|
+
(isVisible: boolean): void;
|
|
140
|
+
(deltaTime: number): void;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
type TEventType = typeof EVENT_DETECTED | typeof EVENT_LOST | typeof EVENT_POSE | typeof EVENT_PROCESS | typeof EVENT_RESIZE | typeof EVENT_DEVICE_ORIENTATION | typeof EVENT_SCREEN_ORIENTATION | typeof EVENT_VISIBILITY | typeof EVENT_FRAME;
|
|
144
|
+
|
|
145
|
+
type TViewportSizes = {
|
|
146
|
+
width: number;
|
|
147
|
+
height: number;
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
type TWAS = {
|
|
151
|
+
canvas: HTMLCanvasElement;
|
|
152
|
+
context: WebGL2RenderingContext | WebGLRenderingContext | null;
|
|
153
|
+
videoCanvas: HTMLCanvasElement;
|
|
154
|
+
viewportSizes: TViewportSizes;
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
type TTriggerSize = {
|
|
158
|
+
id: number;
|
|
159
|
+
width: number;
|
|
160
|
+
height: number;
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
interface IWAS {
|
|
164
|
+
init(configData: TConfigData): Promise<TWAS>;
|
|
165
|
+
on(type: TEventWASType, callBack: TEventWASCallBack): Promise<void>;
|
|
166
|
+
un(type: TEventType): Promise<void>;
|
|
167
|
+
dispose(): Promise<void>;
|
|
168
|
+
setMediaStream(): Promise<void>;
|
|
169
|
+
getTriggerSize(triggerId: number): TTriggerSize | undefined;
|
|
170
|
+
getTriggerScale(triggerId: number): TVector | undefined;
|
|
171
|
+
getViewportSizes(): TViewportSizes;
|
|
172
|
+
getFaceMeshTriangulation(): Uint16Array;
|
|
173
|
+
getFaceMeshTriangulationFillMouth(): Uint16Array;
|
|
174
|
+
getFaceMeshTriangulationFillEyes(): Uint16Array;
|
|
175
|
+
getFaceMeshTriangulationFill(): Uint16Array;
|
|
176
|
+
getFaceMeshUv(): Float32Array;
|
|
177
|
+
getFaceMeshPosition(): Float32Array;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
declare class WAS implements IWAS {
|
|
181
|
+
private configData;
|
|
182
|
+
private video;
|
|
183
|
+
private canvas3D;
|
|
184
|
+
private canvasGrayscale;
|
|
185
|
+
private canvasGrayscale2D;
|
|
186
|
+
private canvasVideo;
|
|
187
|
+
private canvas3DContext;
|
|
188
|
+
private canvasGrayscaleContext;
|
|
189
|
+
private canvasGrayscale2DContext;
|
|
190
|
+
private canvasVideoContext;
|
|
191
|
+
private isSaveFrame;
|
|
192
|
+
private videoWidth;
|
|
193
|
+
private videoHeight;
|
|
194
|
+
private containerWidth;
|
|
195
|
+
private containerHeight;
|
|
196
|
+
private isMessageSent;
|
|
197
|
+
private isMessageSentSetConfig;
|
|
198
|
+
private isNeedToSetConfig;
|
|
199
|
+
private isProcess;
|
|
200
|
+
private countTriggers;
|
|
201
|
+
private triggerSizes;
|
|
202
|
+
private triggerScales;
|
|
203
|
+
private checkPerformance;
|
|
204
|
+
private checkPose;
|
|
205
|
+
private faceLandmarker;
|
|
206
|
+
private faceLandmarkerTime;
|
|
207
|
+
private faceData;
|
|
208
|
+
private readonly fov;
|
|
209
|
+
private readonly near;
|
|
210
|
+
private readonly far;
|
|
211
|
+
private readonly browserManager;
|
|
212
|
+
private readonly eventsManager;
|
|
213
|
+
private readonly dataManager;
|
|
214
|
+
private readonly glManager;
|
|
215
|
+
private readonly workerManager;
|
|
216
|
+
constructor();
|
|
217
|
+
init(configData: TConfigData): Promise<TWAS>;
|
|
218
|
+
on(type: typeof EVENT_DETECTED, callBack: (detectedData: TEventDetectedData[]) => void): Promise<void>;
|
|
219
|
+
on(type: typeof EVENT_LOST, callBack: (lostData: TEventLostData[]) => void): Promise<void>;
|
|
220
|
+
on(type: typeof EVENT_POSE, callBack: (poseData: TEventPoseData[]) => void): Promise<void>;
|
|
221
|
+
on(type: typeof EVENT_PROCESS, callBack: (isProcess: boolean) => void): Promise<void>;
|
|
222
|
+
on(type: typeof EVENT_RESIZE, callBack: (event: UIEvent) => void): Promise<void>;
|
|
223
|
+
on(type: typeof EVENT_DEVICE_ORIENTATION, callBack: (event: DeviceOrientationEvent) => void): Promise<void>;
|
|
224
|
+
on(type: typeof EVENT_SCREEN_ORIENTATION, callBack: (angle: number) => void): Promise<void>;
|
|
225
|
+
on(type: typeof EVENT_VISIBILITY, callBack: (isVisible: boolean) => void): Promise<void>;
|
|
226
|
+
on(type: typeof EVENT_FRAME, callBack: (deltaTime: number) => void): Promise<void>;
|
|
227
|
+
un(type: TEventType): Promise<void>;
|
|
228
|
+
dispose(): Promise<void>;
|
|
229
|
+
private initVideo;
|
|
230
|
+
private initCanvas;
|
|
231
|
+
private initContext;
|
|
232
|
+
setMediaStream(): Promise<void>;
|
|
233
|
+
private updateSizes;
|
|
234
|
+
private setVideoWidth;
|
|
235
|
+
private setVideoHeight;
|
|
236
|
+
private getVideoWidth;
|
|
237
|
+
private getVideoHeight;
|
|
238
|
+
private setContainerWidth;
|
|
239
|
+
private setContainerHeight;
|
|
240
|
+
private getContainerWidth;
|
|
241
|
+
private getContainerHeight;
|
|
242
|
+
private restartMediaStream;
|
|
243
|
+
private setConfig;
|
|
244
|
+
private setTriggers;
|
|
245
|
+
private loadImage;
|
|
246
|
+
private initFaceLandmarker;
|
|
247
|
+
private faceLandmarkerProcess;
|
|
248
|
+
private process;
|
|
249
|
+
private drawVideo;
|
|
250
|
+
getTriggerSize(triggerId: number): TTriggerSize | undefined;
|
|
251
|
+
getTriggerScale(triggerId: number): TVector | undefined;
|
|
252
|
+
getViewportSizes(): TViewportSizes;
|
|
253
|
+
getFaceMeshTriangulation(): Uint16Array;
|
|
254
|
+
getFaceMeshTriangulationFillMouth(): Uint16Array;
|
|
255
|
+
getFaceMeshTriangulationFillEyes(): Uint16Array;
|
|
256
|
+
getFaceMeshTriangulationFill(): Uint16Array;
|
|
257
|
+
getFaceMeshUv(): Float32Array;
|
|
258
|
+
getFaceMeshPosition(): Float32Array;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export { ANCHOR_TYPE_BOTTOM_LEFT, ANCHOR_TYPE_BOTTOM_LIP, ANCHOR_TYPE_BOTTOM_RIGHT, ANCHOR_TYPE_CENTER, ANCHOR_TYPE_CHIN, ANCHOR_TYPE_LEFT_EAR, ANCHOR_TYPE_LEFT_EYE, ANCHOR_TYPE_LEFT_EYEBROW, ANCHOR_TYPE_NOSE_BASE, ANCHOR_TYPE_NOSE_BRIDGE, ANCHOR_TYPE_NOSE_TIP, ANCHOR_TYPE_ORIGIN, ANCHOR_TYPE_RIGHT_EAR, ANCHOR_TYPE_RIGHT_EYE, ANCHOR_TYPE_RIGHT_EYEBROW, ANCHOR_TYPE_TOP_LEFT, ANCHOR_TYPE_TOP_RIGHT, DATA_ERROR, DEVICE_ERROR, EVENT_DETECTED, EVENT_DEVICE_ORIENTATION, EVENT_ERROR, EVENT_FRAME, EVENT_LOST, EVENT_POSE, EVENT_PROCESS, EVENT_RESIZE, EVENT_SCREEN_ORIENTATION, EVENT_VISIBILITY, GL_ERROR, HTML_ERROR, PROJECT_MODE_FACE, PROJECT_MODE_IMAGE, PROJECT_MODE_MIX, PROJECT_MODE_QR, PROJECT_MODE_SLAM_3DOF, type TEventDetectedData, type TEventLostData, type TEventPoseData, TRIGGER_MODE_FACE, TRIGGER_MODE_IMAGE, TRIGGER_MODE_QR, type TTriggerSize, type TViewportSizes, VIDEO_ERROR, WORKER_ERROR, WAS as default };
|
package/package.json
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@web-ar-studio/webar-engine-sdk",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "WAS CV Lib - SDK of the WebAR CV Lib",
|
|
5
|
-
"main": "./dist/index.js",
|
|
6
|
-
"module": "./dist/index.mjs",
|
|
7
|
-
"types": "index.d.ts",
|
|
8
|
-
"typesVersions": {
|
|
9
|
-
">=4.2": {
|
|
10
|
-
"*": [
|
|
11
|
-
"./dist/index.d.ts"
|
|
12
|
-
]
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
"exports": {
|
|
16
|
-
".": {
|
|
17
|
-
"types": "./dist/index.d.ts",
|
|
18
|
-
"require": "./dist/index.js",
|
|
19
|
-
"import": "./dist/index.mjs",
|
|
20
|
-
"default": "./dist/index.mjs"
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
"repository": {
|
|
24
|
-
"type": "git",
|
|
25
|
-
"url": "https://github.com/WebAR-Studio/webar-engine-sdk.git"
|
|
26
|
-
},
|
|
27
|
-
"dependencies": {
|
|
28
|
-
"@mediapipe/tasks-vision": "^0.10.9",
|
|
29
|
-
"gl-matrix": "^3.4.3",
|
|
30
|
-
"ua-parser-js": "^1.0.36"
|
|
31
|
-
}
|
|
32
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@web-ar-studio/webar-engine-sdk",
|
|
3
|
+
"version": "1.0.8",
|
|
4
|
+
"description": "WAS CV Lib - SDK of the WebAR CV Lib",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"types": "index.d.ts",
|
|
8
|
+
"typesVersions": {
|
|
9
|
+
">=4.2": {
|
|
10
|
+
"*": [
|
|
11
|
+
"./dist/index.d.ts"
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"require": "./dist/index.js",
|
|
19
|
+
"import": "./dist/index.mjs",
|
|
20
|
+
"default": "./dist/index.mjs"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "https://github.com/WebAR-Studio/webar-engine-sdk.git"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@mediapipe/tasks-vision": "^0.10.9",
|
|
29
|
+
"gl-matrix": "^3.4.3",
|
|
30
|
+
"ua-parser-js": "^1.0.36"
|
|
31
|
+
}
|
|
32
|
+
}
|