deepar 5.4.2 → 5.4.3-chromeExtension
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/VERSION.txt +1 -1
- package/js/deepar.esm.js +1 -1
- package/js/deepar.js +1 -1
- package/js/types/version.d.ts +1 -1
- package/lib/LICENSE +1 -0
- package/lib/README.md +326 -0
- package/lib/VERSION.txt +1 -0
- package/lib/effects/background_blur.deepar +0 -0
- package/lib/effects/background_replacement.deepar +0 -0
- package/lib/js/deepar.esm.js +1 -0
- package/lib/js/deepar.js +1 -0
- package/lib/js/types/DeepAR.d.ts +387 -0
- package/lib/js/types/callbacks.d.ts +64 -0
- package/lib/js/types/canvasHelper.d.ts +18 -0
- package/lib/js/types/canvasTouchHelper.d.ts +13 -0
- package/lib/js/types/errors.d.ts +6 -0
- package/lib/js/types/faceData.d.ts +33 -0
- package/lib/js/types/footData.d.ts +9 -0
- package/lib/js/types/index.d.ts +10 -0
- package/lib/js/types/initParams.d.ts +236 -0
- package/lib/js/types/logType.d.ts +18 -0
- package/lib/js/types/mediaRecorderVideoRecording.d.ts +10 -0
- package/lib/js/types/scriptingApi.d.ts +107 -0
- package/lib/js/types/touchType.d.ts +34 -0
- package/lib/js/types/version.d.ts +5 -0
- package/lib/js/types/webCodecsVideoRecording.d.ts +11 -0
- package/lib/js/types/wristData.d.ts +13 -0
- package/lib/mediaPipe/segmentation/models/selfie_segmenter.tflite +0 -0
- package/lib/mediaPipe/segmentation/models/selfie_segmenter_landscape.tflite +0 -0
- package/lib/mediaPipe/segmentation/wasm/vision_wasm_internal.js +22 -0
- package/lib/mediaPipe/segmentation/wasm/vision_wasm_internal.wasm +0 -0
- package/lib/mediaPipe/segmentation/wasm/vision_wasm_nosimd_internal.js +22 -0
- package/lib/mediaPipe/segmentation/wasm/vision_wasm_nosimd_internal.wasm +0 -0
- package/lib/models/face/models-68-extreme.bin +0 -0
- package/lib/models/face-cnn/face-det.bin +0 -0
- package/lib/models/face-cnn/face-track-19.bin +0 -0
- package/lib/models/foot/foot-detection-96x96x6.bin +0 -0
- package/lib/models/foot/foot-model.obj +3965 -0
- package/lib/models/foot/foot-tracker-96x96x13-test.bin +0 -0
- package/lib/models/foot/foot-tracker-96x96x18-test.bin +0 -0
- package/lib/models/segmentation/segmentation-160x160-opt.bin +0 -0
- package/lib/models/wrist/wrist-base-2.obj +3815 -0
- package/lib/models/wrist/wrist-det-9.bin +0 -0
- package/lib/models/wrist/wrist-track.bin +0 -0
- package/lib/wasm/deepar.wasm +0 -0
- package/lib/wasm/libxzimgPoseEstimation.wasm +0 -0
- package/lib/wasm/tfjs-backend-wasm-simd.wasm +0 -0
- package/lib/wasm/tfjs-backend-wasm-threaded-simd.wasm +0 -0
- package/lib/wasm/tfjs-backend-wasm.wasm +0 -0
- package/package.json +1 -1
- package/wasm/deepar.wasm +0 -0
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
/// <reference types="dom-mediacapture-transform" />
|
|
2
|
+
import { ARTouchInfo } from "./touchType";
|
|
3
|
+
import { DeepARCallbacks } from "./callbacks";
|
|
4
|
+
import { DeepARParams } from "./initParams";
|
|
5
|
+
import { LogType } from "./logType";
|
|
6
|
+
import { ScriptingAPI } from "./scriptingApi";
|
|
7
|
+
/**
|
|
8
|
+
* Initialize the DeepAR SDK.<br><br>
|
|
9
|
+
* @param params Initialization parameters.
|
|
10
|
+
* @example
|
|
11
|
+
* import * as deepar from 'deepar';
|
|
12
|
+
*
|
|
13
|
+
* let deepAR = deepar.initialize({
|
|
14
|
+
* licenseKey: 'your_license_key_here',
|
|
15
|
+
* canvas: document.getElementById('deepar-canvas')
|
|
16
|
+
* });
|
|
17
|
+
*/
|
|
18
|
+
export declare function initialize(params: DeepARParams): Promise<DeepAR>;
|
|
19
|
+
/**
|
|
20
|
+
* Main class for interacting with DeepAR SDK. To get a DeepAR object call {@link initialize}.
|
|
21
|
+
*/
|
|
22
|
+
export declare class DeepAR {
|
|
23
|
+
/**
|
|
24
|
+
* Emscripten module object. Contains all the exposed C/C++ API. Used for interacting with the native SDK.
|
|
25
|
+
* @private
|
|
26
|
+
*/
|
|
27
|
+
private module;
|
|
28
|
+
private canvasTouchHelper;
|
|
29
|
+
/**
|
|
30
|
+
* Callbacks property is used to add/remove/change callbacks called by the DeepAR SDK. See list of all callbacks at {@link DeepARCallbacks}. <br><br>
|
|
31
|
+
* Example: To add/change certain callback:
|
|
32
|
+
* ```javascript
|
|
33
|
+
* let deepAR = deepar.initialize({...});
|
|
34
|
+
* deepAR.callbacks.onFaceVisibilityChanged = () => {
|
|
35
|
+
* // do something
|
|
36
|
+
* };
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* To remove certain callback:
|
|
40
|
+
* ```javascript
|
|
41
|
+
* deepAR.callbacks.onFaceTracked = undefined;
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
callbacks: DeepARCallbacks;
|
|
45
|
+
/**
|
|
46
|
+
* Scripting API property used to access all the scripting interop methods.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* let scriptingVariable = deepAR.ScriptingAPI.getStringVar('variableName');
|
|
50
|
+
*/
|
|
51
|
+
ScriptingAPI: ScriptingAPI;
|
|
52
|
+
/**
|
|
53
|
+
* @internal
|
|
54
|
+
* @param module
|
|
55
|
+
*/
|
|
56
|
+
constructor(module: any);
|
|
57
|
+
/**
|
|
58
|
+
* Switch the AR effect for preview.
|
|
59
|
+
*
|
|
60
|
+
* @param effect A path (URL) to the AR effect file or an ArrayBuffer object of an already fetched AR effect file.
|
|
61
|
+
* @param effectOptions Effect options.
|
|
62
|
+
* @param effectOptions.slot Default value is "DEFAULT_SLOT" if slot is not given. Slot is a container for a given AR effect. When replacing the already loaded AR effect, call switchEffect with that same slot. To remove AR effect entirely, call {@link clearEffect} with the same slot.
|
|
63
|
+
* @param effectOptions.face If AR effect is face filter, select to which face to attach it to. The value should be between 0 and 3. Default value is 0.
|
|
64
|
+
*
|
|
65
|
+
* @throws {@link errors.SwitchEffectCanceled} If the switch effect is canceled by something.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* // Switch filter 1.
|
|
69
|
+
* await deepAR.switchEffect('url/path/to/filter1');
|
|
70
|
+
* // Later switch fo filter 2.
|
|
71
|
+
* await deepAR.switchEffect('url/path/to/filter2');
|
|
72
|
+
*
|
|
73
|
+
* // Remove the current filter.
|
|
74
|
+
* deepAR.clearEffect();
|
|
75
|
+
*
|
|
76
|
+
* // Put two filters at the same time.
|
|
77
|
+
* await deepAR.switchEffect('url/path/to/backgroundReplacement', {slot: 'background'});
|
|
78
|
+
* await deepAR.switchEffect('url/path/to/glasses', {slot: 'faceMask'});
|
|
79
|
+
* // Replace the glasses filter.
|
|
80
|
+
* await deepAR.switchEffect('url/path/to/glasses2', {slot: 'faceMask'});
|
|
81
|
+
* // Remove those filters.
|
|
82
|
+
* deepAR.clearEffect('background');
|
|
83
|
+
* deepAR.clearEffect('faceMask');
|
|
84
|
+
*
|
|
85
|
+
* // Load filters for two people.
|
|
86
|
+
* await deepAR.switchEffect('url/path/to/faceMask1', {face: 0, slot: 'mask1'});
|
|
87
|
+
* await deepAR.switchEffect('url/path/to/faceMask2', {face: 1, slot: 'mask2'});
|
|
88
|
+
* // Clear effect for the second person.
|
|
89
|
+
* deepAR.clearEffect('mask2');
|
|
90
|
+
*/
|
|
91
|
+
switchEffect(effect: string | ArrayBuffer, effectOptions?: {
|
|
92
|
+
slot?: string;
|
|
93
|
+
face?: number;
|
|
94
|
+
}): Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Clears the given slot of any loaded effects.
|
|
97
|
+
* @param slot The effect slot name. Default is "DEFAULT_SLOT".
|
|
98
|
+
*/
|
|
99
|
+
clearEffect(slot?: string): void;
|
|
100
|
+
/**
|
|
101
|
+
* Captures a screenshot of the current screen.
|
|
102
|
+
* @returns <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs">Data URL</a> promise containing the image in <code>data:image/png</code> format.
|
|
103
|
+
*/
|
|
104
|
+
takeScreenshot(): Promise<string>;
|
|
105
|
+
/**
|
|
106
|
+
* Start video recording of the DeepAR preview.
|
|
107
|
+
*
|
|
108
|
+
* To stop video recording call {@link finishVideoRecording}.
|
|
109
|
+
* By default, the audio is not recorded. To record audio set the recordAudio parameter. Note that if the user did not give the microphone permission, the recording will not start until the permission is granted. If permission is denied, the function will throw.
|
|
110
|
+
* The recorded video will be mp4 on all browsers except Firefox where it will be webm.
|
|
111
|
+
* Audio recording is currently not available on Android.
|
|
112
|
+
*
|
|
113
|
+
* @param options Parameters that specify the format of recorded videos
|
|
114
|
+
* @param options.recordAudio If set, microphone sound will be recorded as well. If this parameter is set, options.audioTrack is ignored.
|
|
115
|
+
* @param options.audioTrack If passed, this audio track is going to be recorded.
|
|
116
|
+
* @param options.audioBitRate Sets audio bit rate. By default 128000.
|
|
117
|
+
* @param options.audioSampleRate Set audio sample rate. On firefox it is 48k. On other browsers defaults to audioTrack.getCapabilities().sampleRate.max or to the value passed here.
|
|
118
|
+
* @param options.videoBitRate Sets video bit rate. By default 4000000.
|
|
119
|
+
* @param options.videoFrameRate Sets video frame rate. By default 30.
|
|
120
|
+
*/
|
|
121
|
+
startVideoRecording(options?: {
|
|
122
|
+
recordAudio?: boolean;
|
|
123
|
+
audioTrack?: MediaStreamAudioTrack;
|
|
124
|
+
audioBitRate?: number;
|
|
125
|
+
audioSampleRate?: number;
|
|
126
|
+
videoBitRate?: number;
|
|
127
|
+
videoFrameRate?: number;
|
|
128
|
+
}): Promise<void>;
|
|
129
|
+
/**
|
|
130
|
+
* Stops the video recording and returns a video blob.
|
|
131
|
+
* @returns A promise resolving to Blob of a video.
|
|
132
|
+
*/
|
|
133
|
+
finishVideoRecording(): Promise<Blob>;
|
|
134
|
+
/**
|
|
135
|
+
* Enable background blur.
|
|
136
|
+
*
|
|
137
|
+
* Background blur is usually used in video calling use cases.
|
|
138
|
+
*
|
|
139
|
+
* @param enable - Boolean indicating whether to enable or disable the background blur effect.
|
|
140
|
+
* @param strength - Blur strength. Integer number in range 1-10.
|
|
141
|
+
*/
|
|
142
|
+
backgroundBlur(enable: boolean, strength: number): Promise<void>;
|
|
143
|
+
/**
|
|
144
|
+
* Enable background replacement (also known as background removal or green screen effect).
|
|
145
|
+
*
|
|
146
|
+
* @param enable - Boolean indicating whether to enable or disable the background replacement effect.
|
|
147
|
+
* @param image - The URL of the image to be used as the background.
|
|
148
|
+
*/
|
|
149
|
+
backgroundReplacement(enable: boolean, image: string): Promise<void>;
|
|
150
|
+
/**
|
|
151
|
+
* Starts the camera preview. By default, the camera will be user facing. The returned promise will resolve after the camera starts
|
|
152
|
+
* or it will reject if camera permission was denied.
|
|
153
|
+
* @param cameraOptions Camera options.
|
|
154
|
+
* @param cameraOptions.mirror Mirror the camera horizontally. True by default.
|
|
155
|
+
* @param cameraOptions.mediaStreamConstraints Options passed to MediaDevices.getUserMedia(). The default is the user facing camera.
|
|
156
|
+
* @param cameraOptions.cameraPermissionAsked Callback called when camera permission is asked.
|
|
157
|
+
* @param cameraOptions.cameraPermissionGranted Callback called when camera permission is granted.
|
|
158
|
+
*/
|
|
159
|
+
startCamera(cameraOptions?: {
|
|
160
|
+
mirror?: boolean;
|
|
161
|
+
mediaStreamConstraints?: MediaStreamConstraints;
|
|
162
|
+
cameraPermissionAsked?: () => void;
|
|
163
|
+
cameraPermissionGranted?: () => void;
|
|
164
|
+
}): Promise<void>;
|
|
165
|
+
/**
|
|
166
|
+
* Stops the camera preview.
|
|
167
|
+
*/
|
|
168
|
+
stopCamera(): void;
|
|
169
|
+
/**
|
|
170
|
+
* Stops the camera preview or custom video preview set by {@link setVideoElement}.
|
|
171
|
+
*/
|
|
172
|
+
stopVideo(): void;
|
|
173
|
+
/**
|
|
174
|
+
* Used to pass the HTMLVideoElement to the DeepAR SDK. The SDK will use this video as camera source. This method should be used instead of {@link DeepAR.startCamera} when you want to handle getUserMedia outside the SDK or you need to apply the masks to any video stream.
|
|
175
|
+
* To disable automatic camera preview by DeepAR:
|
|
176
|
+
* ```js
|
|
177
|
+
* const deepAR = deepar.initialize({
|
|
178
|
+
* // ...
|
|
179
|
+
* additionalOptions: {
|
|
180
|
+
* cameraConfig: {
|
|
181
|
+
* disableDefaultCamera: true
|
|
182
|
+
* }
|
|
183
|
+
* }
|
|
184
|
+
* });
|
|
185
|
+
* ```
|
|
186
|
+
* @param videoElement Video element.
|
|
187
|
+
* @param mirror Mirror the video horizontally.
|
|
188
|
+
*/
|
|
189
|
+
setVideoElement(videoElement: HTMLVideoElement, mirror: boolean): void;
|
|
190
|
+
/**
|
|
191
|
+
* Shutdown the DeepAR SDK and release all resources associated with it. It is invalid to call any function from this {@link DeepAR} object after shutdown.
|
|
192
|
+
* After shutdown call, it is possible to call {@link initialize} again.
|
|
193
|
+
*/
|
|
194
|
+
shutdown(): void;
|
|
195
|
+
/**
|
|
196
|
+
* Mutes or un-mutes all the sounds that are currently playing.
|
|
197
|
+
*
|
|
198
|
+
* @param muteSound true if you want to mute all the sounds.
|
|
199
|
+
*/
|
|
200
|
+
muteSound(muteSound: boolean): void;
|
|
201
|
+
/**
|
|
202
|
+
* Feed RGBA image to DeepAR as input instead of camera or video. Used for processing single image. Can be used instead of {@link startCamera} or {@link setVideoElement}.
|
|
203
|
+
* Can be called in a loop.
|
|
204
|
+
* @param frame Image.
|
|
205
|
+
* @param width Width of the image.
|
|
206
|
+
* @param height Height of the image.
|
|
207
|
+
* @param mirror Mirror frame horizontally.
|
|
208
|
+
*/
|
|
209
|
+
processFrame(frame: Uint8Array, width: number, height: number, mirror: boolean): void;
|
|
210
|
+
/**
|
|
211
|
+
* If you want to apply DeepAR processing on a single image instead of a camera stream use this method. Can be used instead of {@link startCamera} or {@link DeepAR.setVideoElement}. See example usage <a href="https://github.com/DeepARSDK/photoedit-web-js">here</a>.
|
|
212
|
+
* @param image
|
|
213
|
+
*/
|
|
214
|
+
processImage(image: HTMLImageElement): void;
|
|
215
|
+
/**
|
|
216
|
+
* Pauses the DeepAR processing and rendering on canvas.
|
|
217
|
+
* @param isPause If true, DeepAR will pause. Otherwise, it will resume processing and rendering.
|
|
218
|
+
*/
|
|
219
|
+
setPaused(isPause: boolean): void;
|
|
220
|
+
/**
|
|
221
|
+
* Changes a node or component bool parameter of the currently loaded effect. For more details about changeParameter API read our docs <a href="https://docs.deepar.ai/guides-and-tutorials/changing-filter-parameters-from-code">here</a>.
|
|
222
|
+
* @param gameObject The name of the node from DeepAR Studio. If multiple nodes share the same name, only the first one will be affected.
|
|
223
|
+
* @param component The name of the component. If the name of the component is null or an empty string, the node itself will be affected.
|
|
224
|
+
* @param parameter The name of the parameter.
|
|
225
|
+
* @param value New parameter value.
|
|
226
|
+
*/
|
|
227
|
+
changeParameterFloat(gameObject: string, component: string, parameter: string, value: number): void;
|
|
228
|
+
/**
|
|
229
|
+
* Changes a node or component float parameter of the currently loaded effect. For more details about changeParameter API read our docs <a href="https://docs.deepar.ai/guides-and-tutorials/changing-filter-parameters-from-code">here</a>.
|
|
230
|
+
* @param gameObject The name of the node from DeepAR Studio. If multiple nodes share the same name, only the first one will be affected.
|
|
231
|
+
* @param component The name of the component. If the name of the component is null or an empty string, the node itself will be affected.
|
|
232
|
+
* @param parameter The name of the parameter.
|
|
233
|
+
* @param value New parameter value.
|
|
234
|
+
*/
|
|
235
|
+
changeParameterBool(gameObject: string, component: string, parameter: string, value: boolean): void;
|
|
236
|
+
/**
|
|
237
|
+
* Changes a node or component vector parameter of the currently loaded effect. For more details about changeParameter API read our docs <a href="https://docs.deepar.ai/guides-and-tutorials/changing-filter-parameters-from-code">here</a>.
|
|
238
|
+
* @param gameObject The name of the node from DeepAR Studio. If multiple nodes share the same name, only the first one will be affected.
|
|
239
|
+
* @param component The name of the component. If the name of the component is null or an empty string, the node itself will be affected.
|
|
240
|
+
* @param parameter The name of the parameter.
|
|
241
|
+
* @param x X component of the new parameter vector.
|
|
242
|
+
* @param y Y component of the new parameter vector.
|
|
243
|
+
* @param z Z component of the new parameter vector.
|
|
244
|
+
* @param w W component of the new parameter vector.
|
|
245
|
+
*/
|
|
246
|
+
changeParameterVector(gameObject: string, component: string, parameter: string, x: number, y: number, z: number, w: number): void;
|
|
247
|
+
/**
|
|
248
|
+
* Changes a node or component texture parameter of the currently loaded effect. For more details about changeParameter API read our docs <a href="https://docs.deepar.ai/guides-and-tutorials/changing-filter-parameters-from-code">here</a>.
|
|
249
|
+
* @param gameObject The name of the node from DeepAR Studio. If multiple nodes share the same name, only the first one will be affected.
|
|
250
|
+
* @param component The name of the component. If the name of the component is null or an empty string, the node itself will be affected.
|
|
251
|
+
* @param parameter The name of the parameter.
|
|
252
|
+
* @param textureUrl Url of the image that is going to be used as texture.
|
|
253
|
+
*/
|
|
254
|
+
changeParameterTexture(gameObject: string, component: string, parameter: string, textureUrl: string): void;
|
|
255
|
+
/**
|
|
256
|
+
* This method allows the user to fire a custom animation trigger for model animations from code. To fire a custom trigger,
|
|
257
|
+
* the trigger string must match the custom trigger set in the Studio when creating the effect. Read more <a href="https://help.deepar.ai/en/articles/4354740-animations-tutorial-fbx-model-animations">here</a>.
|
|
258
|
+
* @param trigger The name of the trigger.
|
|
259
|
+
*/
|
|
260
|
+
fireTrigger(trigger: string): void;
|
|
261
|
+
/**
|
|
262
|
+
* Change face detection sensitivity
|
|
263
|
+
* @param sensitivity 0 .. 5 (0 is fast, 4,5 is slow but allows to find smaller faces)
|
|
264
|
+
*/
|
|
265
|
+
setFaceDetectionSensitivity(sensitivity: number): void;
|
|
266
|
+
/**
|
|
267
|
+
* Enable/disable forced rendering on the canvas. It is useful to enable offscreen rendering in scenarios when the browser
|
|
268
|
+
* does not call requestAnimationFrame() function. DeepAR internally uses requestAnimationFrame() for the rendering loop.
|
|
269
|
+
* For example, when the browser tab is not focused, the browser will not call requestAnimationFrame() and DeepAR will not
|
|
270
|
+
* render. If offscreen rendering is enabled, DeepAR will use its internal timer for the rendering loop. Note that offscreen
|
|
271
|
+
* rendering enabled will not have as good results in terms of FPS compared to offscreen rendering disabled. <br><br>
|
|
272
|
+
*
|
|
273
|
+
* If you need to use offscreen rendering. The best practice is to enable it only when needed - like when the browser tab is not focused.
|
|
274
|
+
* Otherwise, it is best to always disable offscreen rendering.
|
|
275
|
+
* @param enable True - DeepAR will use its internal timer for the rendering loop. Rendering will work even when tab is not focused. False - DeepAR will use requestAnimationFrame() for the rendering loop.
|
|
276
|
+
*/
|
|
277
|
+
setOffscreenRenderingEnabled(enable: boolean): void;
|
|
278
|
+
/**
|
|
279
|
+
* Retrieves the HTML canvas element used for AR preview.
|
|
280
|
+
*
|
|
281
|
+
* The returned canvas is used for DeepAR rendering of camera preview and AR filters.
|
|
282
|
+
* Most commonly canvas is needed when you want to do some postprocessing on it or feed it
|
|
283
|
+
* into some video calling library.
|
|
284
|
+
*
|
|
285
|
+
* @return {HTMLCanvasElement} The HTML canvas element.
|
|
286
|
+
*/
|
|
287
|
+
getCanvas(): HTMLCanvasElement;
|
|
288
|
+
/**
|
|
289
|
+
* Set the FPS of DeepAR rendering.
|
|
290
|
+
* @param fps New FPS.
|
|
291
|
+
*/
|
|
292
|
+
setFps(fps: number): void;
|
|
293
|
+
/**
|
|
294
|
+
* Initialize foot tracking.<br><br>
|
|
295
|
+
*
|
|
296
|
+
* Foot tracking is usually lazy loaded on demand when filter loaded with {@link switchEffect} requires it.
|
|
297
|
+
* But this method will start loading the foot tracking immediately.
|
|
298
|
+
* To start initializing foot tracking as soon as possible pass "footInit" hint in the {@link initialize} function (see {@link DeepARParams}). <br><br>
|
|
299
|
+
*
|
|
300
|
+
* If the foot tracking is already initialized it will do nothing.
|
|
301
|
+
* To check if foot tracking is initialized call {@link isFootTrackingInitialized} or wait {@link DeepARCallbacks.onFootTrackingInitialized} callback.
|
|
302
|
+
*/
|
|
303
|
+
initializeFootTracking(): void;
|
|
304
|
+
/**
|
|
305
|
+
* Check weather the foot tracking is initialized.
|
|
306
|
+
*/
|
|
307
|
+
isFootTrackingInitialized(): boolean;
|
|
308
|
+
/**
|
|
309
|
+
* Initialize segmentation.<br><br>
|
|
310
|
+
*
|
|
311
|
+
* Segmentation is usually lazy loaded on demand when filter loaded with {@link switchEffect} requires it.
|
|
312
|
+
* But this method will start loading the segmentation immediately.
|
|
313
|
+
* To start initializing segmentation as soon as possible pass "segmentationInit" hint in the {@link initialize} function (see {@link DeepARParams}). <br><br>
|
|
314
|
+
*
|
|
315
|
+
* If the segmentation is already initialized it will do nothing.
|
|
316
|
+
* To check if segmentation is initialized call {@link isSegmentationInitialized} or wait {@link DeepARCallbacks.onSegmentationInitialized} callback.
|
|
317
|
+
*/
|
|
318
|
+
initializeSegmentation(): void;
|
|
319
|
+
/**
|
|
320
|
+
* Check weather the segmentation is initialized.
|
|
321
|
+
*/
|
|
322
|
+
isSegmentationInitialized(): boolean;
|
|
323
|
+
/**
|
|
324
|
+
* Check weather the wrist tracking is initialized.
|
|
325
|
+
*/
|
|
326
|
+
isWristTrackingInitialized(): boolean;
|
|
327
|
+
/**
|
|
328
|
+
* Display profiling metrics on preview.
|
|
329
|
+
* @param enabled
|
|
330
|
+
*/
|
|
331
|
+
showStats(enabled: boolean): void;
|
|
332
|
+
/**
|
|
333
|
+
* Enable or disable global physics simulation.
|
|
334
|
+
* @param enabled
|
|
335
|
+
*/
|
|
336
|
+
simulatePhysics(enabled: boolean): void;
|
|
337
|
+
/**
|
|
338
|
+
* Moves the selected game object from its current position in a tree and sets it as a direct child of a target game object.
|
|
339
|
+
* This is equivalent to moving around a node in the node hierarchy in the DeepAR Studio.
|
|
340
|
+
* @param selectedGameObject Node to move.
|
|
341
|
+
* @param targetGameObject New node parent.
|
|
342
|
+
*/
|
|
343
|
+
moveGameObject(selectedGameObject: string, targetGameObject: string): void;
|
|
344
|
+
/**
|
|
345
|
+
* Informs DeepAR that the specified touch event occurred.
|
|
346
|
+
*
|
|
347
|
+
* @deprecated
|
|
348
|
+
* Since version 5.4.0 DeepAR will automatically register touch events from canvas.
|
|
349
|
+
* There is no need to call this function anymore.
|
|
350
|
+
*
|
|
351
|
+
* @param touchInfo Touch event information.
|
|
352
|
+
*/
|
|
353
|
+
touchOccurred(touchInfo: ARTouchInfo): void;
|
|
354
|
+
/** INTERNAL API **/
|
|
355
|
+
/**
|
|
356
|
+
* @internal
|
|
357
|
+
* @param enable
|
|
358
|
+
*/
|
|
359
|
+
enableAutoframing(enable: boolean): void;
|
|
360
|
+
/**
|
|
361
|
+
* @internal
|
|
362
|
+
* Returns all the messages pushed to the console log buffer and empties
|
|
363
|
+
* the buffer.
|
|
364
|
+
* @returns All the messages from console log buffer.
|
|
365
|
+
*/
|
|
366
|
+
getConsoleLogs(): any;
|
|
367
|
+
/**
|
|
368
|
+
* @internal
|
|
369
|
+
* Pushes message to the console log buffer.
|
|
370
|
+
* @param message Message to be pushed to the console log buffer.
|
|
371
|
+
* @param logType Logging type.
|
|
372
|
+
* @returns true if the message was successfully pushed, false otherwise
|
|
373
|
+
*/
|
|
374
|
+
pushConsoleLog(message: string, logType: LogType): boolean;
|
|
375
|
+
/**
|
|
376
|
+
* @internal
|
|
377
|
+
* Display physics colliders preview on screen.
|
|
378
|
+
* @param enabled
|
|
379
|
+
*/
|
|
380
|
+
showColliders(enabled: boolean): void;
|
|
381
|
+
/**
|
|
382
|
+
* Sets the preview zoom.
|
|
383
|
+
*
|
|
384
|
+
* @param zoomLevel Floating point number determining how much to zoom in. Value <= 1 will disable zoom. Example, value 2.0 puts 2x zoom.
|
|
385
|
+
*/
|
|
386
|
+
setZoom(zoomLevel: number): void;
|
|
387
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { FaceData } from "./faceData";
|
|
2
|
+
import { FootData } from "./footData";
|
|
3
|
+
import { WristData } from "./wristData";
|
|
4
|
+
/**
|
|
5
|
+
* Callbacks from DeepAR notifying events.
|
|
6
|
+
* Register callbacks with {@link DeepAR.callbacks}.
|
|
7
|
+
*/
|
|
8
|
+
export interface DeepARCallbacks {
|
|
9
|
+
/**
|
|
10
|
+
* Called whenever the face enters or exits the camera field of view. <br>
|
|
11
|
+
* NOTE: This callback is only called when the SDK does face tracking. For example, you laded some effect that uses face tracking (most of them do). But if no effect is loaded this callback will not get called because the SDK is not performing face tracking.
|
|
12
|
+
* @param visible True if the face is visible on the camera, false otherwise.
|
|
13
|
+
*/
|
|
14
|
+
onFaceVisibilityChanged?: (visible: boolean) => void;
|
|
15
|
+
/**
|
|
16
|
+
* Passes the information about the detected faces. If this callback is set, it will get called every frame.
|
|
17
|
+
* NOTE: This callback is only called when the SDK does face tracking. For example, you laded some effect that uses face tracking (most of them do). But if no effect is loaded this callback will not get called because the SDK is not performing face tracking.
|
|
18
|
+
* @param faceDataArray Information about all the tracked faces.
|
|
19
|
+
*/
|
|
20
|
+
onFaceTracked?: (faceDataArray: FaceData[]) => void;
|
|
21
|
+
/**
|
|
22
|
+
* Passes the information about the detected feet. If this callback is set, it will get called every frame.
|
|
23
|
+
* NOTE: This callback is only called when the SDK does foot tracking. For example, you laded some effect that uses foot tracking (shoe-try-on effects). But if no effect is loaded this callback will not get called because the SDK is not performing foot tracking.
|
|
24
|
+
* @param leftFootData Information about the left foot.
|
|
25
|
+
* @param rightFootData Information about the right foot.
|
|
26
|
+
*/
|
|
27
|
+
onFeetTracked?: (leftFootData: FootData, rightFootData: FootData) => void;
|
|
28
|
+
/**
|
|
29
|
+
* Passes the information about the detected wrist. If this callback is set, it will get called every frame.
|
|
30
|
+
* NOTE: This callback is only called when the SDK does wrist tracking. For example, you laded some effect that uses wrist tracking (watch-try-on effects). But if no effect is loaded this callback will not get called because the SDK is not performing wrist tracking.
|
|
31
|
+
* @param wristData Information about the wrist.
|
|
32
|
+
*/
|
|
33
|
+
onWristTracked?: (wristData: WristData) => void;
|
|
34
|
+
/**
|
|
35
|
+
* Called when foot tracking is fully initialized.
|
|
36
|
+
* Be sure to check {@link DeepAR.isFootTrackingInitialized} before setting this callback.
|
|
37
|
+
* Because this callback is called only once. So if you set this callback after the foot tracking is initialized, it will not be called again.
|
|
38
|
+
*/
|
|
39
|
+
onFootTrackingInitialized?: () => void;
|
|
40
|
+
/**
|
|
41
|
+
* Called when segmentation is fully initialized.
|
|
42
|
+
* Be sure to check {@link DeepAR.isSegmentationInitialized} before setting this callback.
|
|
43
|
+
* Because this callback is called only once. So if you set this callback after the segmentation is initialized, it will not be called again.
|
|
44
|
+
*/
|
|
45
|
+
onSegmentationInitialized?: () => void;
|
|
46
|
+
/**
|
|
47
|
+
* Called when wrist tracking is fully initialized.
|
|
48
|
+
* Be sure to check {@link DeepAR.isWristTrackingInitialized} before setting this callback.
|
|
49
|
+
* Because this callback is called only once. So if you set this callback after the wrist tracking is initialized, it will not be called again.
|
|
50
|
+
*/
|
|
51
|
+
onWristTrackingInitialized?: () => void;
|
|
52
|
+
/**
|
|
53
|
+
* Called when the animation player transitions to a new state.
|
|
54
|
+
* @param newState Name of the new state that is being transitioned to.
|
|
55
|
+
*/
|
|
56
|
+
onAnimationTransitionedToState?: (newState: string) => void;
|
|
57
|
+
/**
|
|
58
|
+
* An internal callback called on every render().
|
|
59
|
+
* @param canvas A canvas containing input camera image that DeepAR used for rendering/tracking.
|
|
60
|
+
* @internal
|
|
61
|
+
*/
|
|
62
|
+
__deeparRendered?: (canvas: HTMLCanvasElement) => void;
|
|
63
|
+
__deeparRendered2?: (canvas: HTMLCanvasElement) => void;
|
|
64
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Function that needs to be called before every render.
|
|
3
|
+
*/
|
|
4
|
+
declare const preRenderUpdate: () => void;
|
|
5
|
+
/**
|
|
6
|
+
* Function that needs to be called after every render.
|
|
7
|
+
*/
|
|
8
|
+
declare const postRenderUpdate: () => void;
|
|
9
|
+
/**
|
|
10
|
+
* Creates a canvas and appends it to the target element.
|
|
11
|
+
* @param previewElement
|
|
12
|
+
*/
|
|
13
|
+
declare function createCanvas(previewElement: HTMLElement): HTMLCanvasElement;
|
|
14
|
+
/**
|
|
15
|
+
* Removes the created canvas and invalidates the current context.
|
|
16
|
+
*/
|
|
17
|
+
declare function invalidate(): void;
|
|
18
|
+
export { preRenderUpdate, postRenderUpdate, createCanvas, invalidate };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ARTouchInfo } from "./touchType";
|
|
2
|
+
export declare class CanvasTouchHelper {
|
|
3
|
+
private canvas;
|
|
4
|
+
private canvasListeners;
|
|
5
|
+
private touchOccurring;
|
|
6
|
+
private touchListeners;
|
|
7
|
+
constructor(canvas: HTMLCanvasElement, listener: (info: ARTouchInfo) => void | null);
|
|
8
|
+
cleanUpCanvasListeners(): void;
|
|
9
|
+
addTouchListener(listener: (info: ARTouchInfo) => void): void;
|
|
10
|
+
private touchOccurred;
|
|
11
|
+
private registerCanvasListener;
|
|
12
|
+
private touchInfo;
|
|
13
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Information about the face being tracked. FaceData object is constructed and passed in the {@link DeepARCallbacks.onFaceTracked} callback.
|
|
3
|
+
*/
|
|
4
|
+
export interface FaceData {
|
|
5
|
+
/**
|
|
6
|
+
* True if the face is detected, false otherwise.
|
|
7
|
+
*/
|
|
8
|
+
detected: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Array of 3 floats containing (x, y, z) position (translation) of the face in 3D space.
|
|
11
|
+
*/
|
|
12
|
+
translation: number[];
|
|
13
|
+
/**
|
|
14
|
+
* Array of 3 floats containing (x, y, z) rotation of the face in 3D space.
|
|
15
|
+
*/
|
|
16
|
+
rotation: number[];
|
|
17
|
+
/**
|
|
18
|
+
* Array of 16 floats containing 4x4 matrix representing translation and rotation of the face in 3D space.
|
|
19
|
+
*/
|
|
20
|
+
poseMatrix: number[];
|
|
21
|
+
/**
|
|
22
|
+
* Array of 63*3 floats containing (x, y, z) positions of the 3D face landmarks. Read more <a href="https://help.deepar.ai/en/articles/4351347-deepar-reference-tracking-models">here</a>.
|
|
23
|
+
*/
|
|
24
|
+
landmarks: number[];
|
|
25
|
+
/**
|
|
26
|
+
* Array of 63*2 floats containing (x, y) positions of the 2D face landmarks in screen space. Usually more precise than 3D points but no estimation for z translation. Read more here about feature points. Read more <a href="https://help.deepar.ai/en/articles/4351347-deepar-reference-tracking-models">here</a>.
|
|
27
|
+
*/
|
|
28
|
+
landmarks2d: number[];
|
|
29
|
+
/**
|
|
30
|
+
* Array of 4 floats. Rectangle (x, y, width, height) containing the face in screen coordinates.
|
|
31
|
+
*/
|
|
32
|
+
faceRect: number[];
|
|
33
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Information about the feet being tracked. FootData object is constructed and passed in the {@link DeepARCallbacks.onFeetTracked} callback.
|
|
3
|
+
*/
|
|
4
|
+
export interface FootData {
|
|
5
|
+
/**
|
|
6
|
+
* True if the foot is detected, false otherwise.
|
|
7
|
+
*/
|
|
8
|
+
detected: boolean;
|
|
9
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './version';
|
|
2
|
+
export * from './DeepAR';
|
|
3
|
+
export * from './initParams';
|
|
4
|
+
export * from './callbacks';
|
|
5
|
+
export * from './faceData';
|
|
6
|
+
export * from './footData';
|
|
7
|
+
export * from './wristData';
|
|
8
|
+
export * from './scriptingApi';
|
|
9
|
+
export * as errors from './errors';
|
|
10
|
+
export * from './touchType';
|