deepar 4.1.0 → 5.0.0-alpha-1
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 +119 -131
- package/effects/aviators +0 -0
- package/effects/dalmatian +0 -0
- package/effects/koala +0 -0
- package/effects/lion +0 -0
- package/js/deepar.esm.js +1 -1
- package/js/deepar.js +1 -1
- package/js/types/DeepAR.d.ts +293 -0
- package/js/types/callbacks.d.ts +42 -0
- package/js/types/faceData.d.ts +33 -0
- package/js/types/footData.d.ts +9 -0
- package/js/types/footTrackingConfig.d.ts +21 -0
- package/js/types/index.d.ts +7 -0
- package/js/types/initParams.d.ts +101 -0
- package/js/types/logType.d.ts +18 -0
- package/js/types/platformDetect.d.ts +17 -0
- package/js/types/touchType.d.ts +34 -0
- package/js/types/version.d.ts +5 -0
- package/js/types/videoRecordingOptions.d.ts +14 -0
- package/js/types/wrapper.d.ts +10 -0
- package/package.json +9 -3
- package/wasm/deepar.wasm +0 -0
- package/js/deepar.d.ts +0 -492
- package/js/deepar.esm.d.ts +0 -492
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import { ARTouchInfo } from "./touchType";
|
|
2
|
+
import { DeepARCallbacks } from "./callbacks";
|
|
3
|
+
import { DeepARParams } from "./initParams";
|
|
4
|
+
import { LogType } from "./logType";
|
|
5
|
+
/**
|
|
6
|
+
* Initialize the DeepAR SDK.<br><br>
|
|
7
|
+
* @param params Initialization parameters.
|
|
8
|
+
* @example
|
|
9
|
+
* import * as deepar from 'deepar';
|
|
10
|
+
*
|
|
11
|
+
* let deepAR = deepar.initialize({
|
|
12
|
+
* licenseKey: 'your_license_key_here',
|
|
13
|
+
* canvas: document.getElementById('deepar-canvas')
|
|
14
|
+
* });
|
|
15
|
+
*/
|
|
16
|
+
export declare function initialize(params: DeepARParams): Promise<DeepAR>;
|
|
17
|
+
/**
|
|
18
|
+
* Main class for interacting with DeepAR SDK. To get a DeepAR object call {@link initialize}.
|
|
19
|
+
*/
|
|
20
|
+
export declare class DeepAR {
|
|
21
|
+
/**
|
|
22
|
+
* Emscripten module object. Contains all the exposed C/C++ API. Used for interacting with the native SDK.
|
|
23
|
+
* @private
|
|
24
|
+
*/
|
|
25
|
+
private module;
|
|
26
|
+
/**
|
|
27
|
+
* Callbacks property is used to add/remove/change callbacks called by the DeepAR SDK. See list of all callbacks at {@link DeepARCallbacks}. <br><br>
|
|
28
|
+
* Example: To add/change certain callback:
|
|
29
|
+
* ```javascript
|
|
30
|
+
* let deepAR = deepar.initialize({...});
|
|
31
|
+
* deepAR.callbacks.onFaceVisibilityChanged = () => {
|
|
32
|
+
* // do something
|
|
33
|
+
* };
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* To remove certain callback:
|
|
37
|
+
* ```javascript
|
|
38
|
+
* deepAR.callbacks.onFaceTracked = undefined;
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
callbacks: DeepARCallbacks;
|
|
42
|
+
/**
|
|
43
|
+
* @internal
|
|
44
|
+
* @param module
|
|
45
|
+
*/
|
|
46
|
+
constructor(module: any);
|
|
47
|
+
/**
|
|
48
|
+
* Switch the AR effect for preview.
|
|
49
|
+
*
|
|
50
|
+
* @param effect A path (URL) to the AR effect file or an ArrayBuffer object of an already fetched AR effect file.
|
|
51
|
+
* @param effectOptions Effect options.
|
|
52
|
+
* @param effectOptions.slot Default value is "mask" 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.
|
|
53
|
+
* @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.
|
|
54
|
+
*
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* // Switch filter 1.
|
|
58
|
+
* deepAR.switchEffect('url/path/to/filter1');
|
|
59
|
+
* // Later switch fo filter 2.
|
|
60
|
+
* deepAR.switchEffect('url/path/to/filter2');
|
|
61
|
+
*
|
|
62
|
+
* // Remove the current filter.
|
|
63
|
+
* deepAR.clearEffect();
|
|
64
|
+
*
|
|
65
|
+
* // Put two filters at the same time.
|
|
66
|
+
* deepAR.switchEffect('url/path/to/backgroundReplacement', {slot: 'background'});
|
|
67
|
+
* deepAR.switchEffect('url/path/to/glasses', {slot: 'faceMask'});
|
|
68
|
+
* // Replace the glasses filter.
|
|
69
|
+
* deepAR.switchEffect('url/path/to/glasses2', {slot: 'faceMask'});
|
|
70
|
+
* // Remove those filters.
|
|
71
|
+
* deepAR.clearEffect('background');
|
|
72
|
+
* deepAR.clearEffect('faceMask');
|
|
73
|
+
*/
|
|
74
|
+
switchEffect(effect: string | ArrayBuffer, effectOptions?: {
|
|
75
|
+
slot?: string;
|
|
76
|
+
face?: number;
|
|
77
|
+
}): Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* Clears the given slot of any loaded effects.
|
|
80
|
+
* @param slot The effect slot name.
|
|
81
|
+
*/
|
|
82
|
+
clearEffect(slot?: string): void;
|
|
83
|
+
/**
|
|
84
|
+
* Captures a screenshot of the current screen.
|
|
85
|
+
* @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.
|
|
86
|
+
*/
|
|
87
|
+
takeScreenshot(): Promise<string>;
|
|
88
|
+
/**
|
|
89
|
+
* Starts video recording of the canvas.
|
|
90
|
+
* @param options Parameters that specify the format of recorded videos
|
|
91
|
+
* @param options.mimeType A MIME type specifying the format for the resulting video, such as `video/webm` or `video/mp4`. Corresponds to the MIME type used by <a href="https://developer.mozilla.org/en-US/docs/Web/API/Blob">Blob</a>objects and <a href="https://developer.mozilla.org/en-US/docs/Web/API/MediaRecorder">MediaRecorder</a>from the MediaStream Recording API. Note that `video/mp4` may not be supported in all browsers.
|
|
92
|
+
*/
|
|
93
|
+
startVideoRecording(options?: {
|
|
94
|
+
mimeType?: string;
|
|
95
|
+
}): void;
|
|
96
|
+
/**
|
|
97
|
+
* Stops the video recording and returns a video blob.
|
|
98
|
+
* @returns A promise resolving to Blob of a video.
|
|
99
|
+
*/
|
|
100
|
+
finishVideoRecording(): Promise<Blob>;
|
|
101
|
+
/**
|
|
102
|
+
* Starts the camera preview. By default, the camera will be user facing.
|
|
103
|
+
* @param mirror Mirror the camera horizontally.
|
|
104
|
+
* @param mediaStreamConstraints Options passed to MediaDevices.getUserMedia(). The default is the user facing camera.
|
|
105
|
+
*/
|
|
106
|
+
startCamera(mirror?: boolean, mediaStreamConstraints?: MediaStreamConstraints): void;
|
|
107
|
+
/**
|
|
108
|
+
* Stops the camera preview or custom video preview set by {@link setVideoElement}.
|
|
109
|
+
*/
|
|
110
|
+
stopVideo(): void;
|
|
111
|
+
/**
|
|
112
|
+
* 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.
|
|
113
|
+
* To disable automatic camera preview by DeepAR:
|
|
114
|
+
* ```js
|
|
115
|
+
* const deepAR = deepar.initialize({
|
|
116
|
+
* // ...
|
|
117
|
+
* additionalOptions: {
|
|
118
|
+
* cameraConfig: {
|
|
119
|
+
* disableDefaultCamera: true
|
|
120
|
+
* }
|
|
121
|
+
* }
|
|
122
|
+
* });
|
|
123
|
+
* ```
|
|
124
|
+
* @param videoElement Video element.
|
|
125
|
+
* @param mirror Mirror the video horizontally.
|
|
126
|
+
*/
|
|
127
|
+
setVideoElement(videoElement: HTMLVideoElement, mirror: boolean): void;
|
|
128
|
+
/**
|
|
129
|
+
* 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.
|
|
130
|
+
* After shutdown call, it is possible to call {@link initialize} again.
|
|
131
|
+
*/
|
|
132
|
+
shutdown(): void;
|
|
133
|
+
/**
|
|
134
|
+
* Process RGBA image. Used for processing single image. Can be used instead of {@link startCamera} or {@link setVideoElement}.
|
|
135
|
+
* @param frame Image.
|
|
136
|
+
* @param width Width of the image.
|
|
137
|
+
* @param height Height of the image.
|
|
138
|
+
* @param mirror Mirror frame horizontally.
|
|
139
|
+
*/
|
|
140
|
+
processFrame(frame: Uint8Array, width: number, height: number, mirror: boolean): void;
|
|
141
|
+
/**
|
|
142
|
+
* 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>.
|
|
143
|
+
* @param image
|
|
144
|
+
*/
|
|
145
|
+
processImage(image: HTMLImageElement): void;
|
|
146
|
+
/**
|
|
147
|
+
* Pauses the DeepAR processing and rendering on canvas.
|
|
148
|
+
* @param isPause If true, DeepAR will pause. Otherwise, it will resume processing and rendering.
|
|
149
|
+
*/
|
|
150
|
+
pause(isPause: boolean): void;
|
|
151
|
+
/**
|
|
152
|
+
* 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>.
|
|
153
|
+
* @param gameObject The name of the node from DeepAR Studio. If multiple nodes share the same name, only the first one will be affected.
|
|
154
|
+
* @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.
|
|
155
|
+
* @param parameter The name of the parameter.
|
|
156
|
+
* @param value New parameter value.
|
|
157
|
+
*/
|
|
158
|
+
changeParameterFloat(gameObject: string, component: string, parameter: string, value: number): void;
|
|
159
|
+
/**
|
|
160
|
+
* 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>.
|
|
161
|
+
* @param gameObject The name of the node from DeepAR Studio. If multiple nodes share the same name, only the first one will be affected.
|
|
162
|
+
* @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.
|
|
163
|
+
* @param parameter The name of the parameter.
|
|
164
|
+
* @param value New parameter value.
|
|
165
|
+
*/
|
|
166
|
+
changeParameterBool(gameObject: string, component: string, parameter: string, value: boolean): void;
|
|
167
|
+
/**
|
|
168
|
+
* 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>.
|
|
169
|
+
* @param gameObject The name of the node from DeepAR Studio. If multiple nodes share the same name, only the first one will be affected.
|
|
170
|
+
* @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.
|
|
171
|
+
* @param parameter The name of the parameter.
|
|
172
|
+
* @param x X component of the new parameter vector.
|
|
173
|
+
* @param y Y component of the new parameter vector.
|
|
174
|
+
* @param z Z component of the new parameter vector.
|
|
175
|
+
* @param w W component of the new parameter vector.
|
|
176
|
+
*/
|
|
177
|
+
changeParameterVector(gameObject: string, component: string, parameter: string, x: number, y: number, z: number, w: number): void;
|
|
178
|
+
/**
|
|
179
|
+
* 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>.
|
|
180
|
+
* @param gameObject The name of the node from DeepAR Studio. If multiple nodes share the same name, only the first one will be affected.
|
|
181
|
+
* @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.
|
|
182
|
+
* @param parameter The name of the parameter.
|
|
183
|
+
* @param textureUrl Url of the image that is going to be used as texture.
|
|
184
|
+
*/
|
|
185
|
+
changeParameterTexture(gameObject: string, component: string, parameter: string, textureUrl: string): void;
|
|
186
|
+
/**
|
|
187
|
+
* This method allows the user to fire a custom animation trigger for model animations from code. To fire a custom trigger,
|
|
188
|
+
* 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>.
|
|
189
|
+
* @param trigger The name of the trigger.
|
|
190
|
+
*/
|
|
191
|
+
fireTrigger(trigger: string): void;
|
|
192
|
+
/**
|
|
193
|
+
* Informs DeepAR that the specified touch event occurred.
|
|
194
|
+
* @param touchInfo Touch event information.
|
|
195
|
+
*/
|
|
196
|
+
touchOccurred(touchInfo: ARTouchInfo): void;
|
|
197
|
+
/**
|
|
198
|
+
* Change face detection sensitivity
|
|
199
|
+
* @param sensitivity 0 .. 5 (0 is fast, 4,5 is slow but allows to find smaller faces)
|
|
200
|
+
*/
|
|
201
|
+
setFaceDetectionSensitivity(sensitivity: number): void;
|
|
202
|
+
/**
|
|
203
|
+
* Enable/disable forced rendering on the canvas. It is useful to enable offscreen rendering in scenarios when the browser
|
|
204
|
+
* does not call requestAnimationFrame() function. DeepAR internally uses requestAnimationFrame() for the rendering loop.
|
|
205
|
+
* For example, when the browser tab is not focused, the browser will not call requestAnimationFrame() and DeepAR will not
|
|
206
|
+
* render. If offscreen rendering is enabled, DeepAR will use its internal timer for the rendering loop. Note that offscreen
|
|
207
|
+
* rendering enabled will not have as good results in terms of FPS compared to offscreen rendering disabled. <br><br>
|
|
208
|
+
*
|
|
209
|
+
* 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.
|
|
210
|
+
* Otherwise, it is best to always disable offscreen rendering.
|
|
211
|
+
* @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.
|
|
212
|
+
*/
|
|
213
|
+
setOffscreenRenderingEnabled(enable: boolean): void;
|
|
214
|
+
/**
|
|
215
|
+
* Set the FPS of DeepAR rendering.
|
|
216
|
+
* @param fps New FPS.
|
|
217
|
+
*/
|
|
218
|
+
setFps(fps: number): void;
|
|
219
|
+
/**
|
|
220
|
+
* Initialize foot tracking.<br><br>
|
|
221
|
+
*
|
|
222
|
+
* Foot tracking is usually lazy loaded on demand when filter loaded with {@link switchEffect} requires it.
|
|
223
|
+
* But this method will start loading the foot tracking immediately.
|
|
224
|
+
* To start initializing foot tracking as soon as possible pass "foot" hint in the {@link initialize} function (see {@link DeepARParams}). <br><br>
|
|
225
|
+
*
|
|
226
|
+
* If the foot tracking is already initialized it will do nothing.
|
|
227
|
+
* To check if foot tracking is initialized call {@link isFootTrackingInitialized} or wait {@link DeepARCallbacks.onFootTrackingInitialized} callback.
|
|
228
|
+
*/
|
|
229
|
+
initializeFootTracking(): void;
|
|
230
|
+
/**
|
|
231
|
+
* Check weather the foot tracking is initialized.
|
|
232
|
+
*/
|
|
233
|
+
isFootTrackingInitialized(): boolean;
|
|
234
|
+
/**
|
|
235
|
+
* Initialize segmentation.<br><br>
|
|
236
|
+
*
|
|
237
|
+
* Segmentation is usually lazy loaded on demand when filter loaded with {@link switchEffect} requires it.
|
|
238
|
+
* But this method will start loading the segmentation immediately.
|
|
239
|
+
* To start initializing foot tracking as soon as possible pass "segmentation" hint in the {@link initialize} function (see {@link DeepARParams}). <br><br>
|
|
240
|
+
*
|
|
241
|
+
* If the segmentation is already initialized it will do nothing.
|
|
242
|
+
* To check if segmentation is initialized call {@link isSegmentationInitialized} or wait {@link DeepARCallbacks.onSegmentationInitialized} callback.
|
|
243
|
+
*/
|
|
244
|
+
initializeSegmentation(): void;
|
|
245
|
+
/**
|
|
246
|
+
* Check weather the segmentation is initialized.
|
|
247
|
+
*/
|
|
248
|
+
isSegmentationInitialized(): boolean;
|
|
249
|
+
/**
|
|
250
|
+
* Display profiling metrics on preview.
|
|
251
|
+
* @param enabled
|
|
252
|
+
*/
|
|
253
|
+
showStats(enabled: boolean): void;
|
|
254
|
+
/**
|
|
255
|
+
* Enable or disable global physics simulation.
|
|
256
|
+
* @param enabled
|
|
257
|
+
*/
|
|
258
|
+
simulatePhysics(enabled: boolean): void;
|
|
259
|
+
/**
|
|
260
|
+
* Moves the selected game object from its current position in a tree and sets it as a direct child of a target game object.
|
|
261
|
+
* This is equivalent to moving around a node in the node hierarchy in the DeepAR Studio.
|
|
262
|
+
* @param selectedGameObject Node to move.
|
|
263
|
+
* @param targetGameObject New node parent.
|
|
264
|
+
*/
|
|
265
|
+
moveGameObject(selectedGameObject: string, targetGameObject: string): void;
|
|
266
|
+
/** INTERNAL API **/
|
|
267
|
+
/**
|
|
268
|
+
* @internal
|
|
269
|
+
* @param enable
|
|
270
|
+
*/
|
|
271
|
+
enableAutoframing(enable: boolean): void;
|
|
272
|
+
/**
|
|
273
|
+
* @internal
|
|
274
|
+
* Returns all the messages pushed to the console log buffer and empties
|
|
275
|
+
* the buffer.
|
|
276
|
+
* @returns All the messages from console log buffer.
|
|
277
|
+
*/
|
|
278
|
+
getConsoleLogs(): any;
|
|
279
|
+
/**
|
|
280
|
+
* @internal
|
|
281
|
+
* Pushes message to the console log buffer.
|
|
282
|
+
* @param message Message to be pushed to the console log buffer.
|
|
283
|
+
* @param logType Logging type.
|
|
284
|
+
* @returns true if the message was successfully pushed, false otherwise
|
|
285
|
+
*/
|
|
286
|
+
pushConsoleLog(message: string, logType: LogType): boolean;
|
|
287
|
+
/**
|
|
288
|
+
* @internal
|
|
289
|
+
* Display physics colliders preview on screen.
|
|
290
|
+
* @param enabled
|
|
291
|
+
*/
|
|
292
|
+
showColliders(enabled: boolean): void;
|
|
293
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { FaceData } from "./faceData";
|
|
2
|
+
import { FootData } from "./footData";
|
|
3
|
+
/**
|
|
4
|
+
* Callbacks from DeepAR notifying events.
|
|
5
|
+
* Register callbacks with {@link DeepAR.callbacks}.
|
|
6
|
+
*/
|
|
7
|
+
export interface DeepARCallbacks {
|
|
8
|
+
/**
|
|
9
|
+
* Called whenever the face enters or exits the camera field of view. <br>
|
|
10
|
+
* 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.
|
|
11
|
+
* @param visible True if the face is visible on the camera, false otherwise.
|
|
12
|
+
*/
|
|
13
|
+
onFaceVisibilityChanged?: (visible: boolean) => void;
|
|
14
|
+
/**
|
|
15
|
+
* Passes the information about the detected faces. If this callback is set, it will get called every frame when a face is detected.
|
|
16
|
+
* @param faceDataArray Information about all the tracked faces.
|
|
17
|
+
*/
|
|
18
|
+
onFaceTracked?: (faceDataArray: FaceData[]) => void;
|
|
19
|
+
/**
|
|
20
|
+
* Passes the information about the detected feet. If this callback is set, it will get called every frame when a foot is detected.
|
|
21
|
+
* @param leftFootData Information about the left foot.
|
|
22
|
+
* @param rightFootData Information about the right foot.
|
|
23
|
+
*/
|
|
24
|
+
onFeetTracked?: (leftFootData: FootData, rightFootData: FootData) => void;
|
|
25
|
+
/**
|
|
26
|
+
* Called when foot tracking is fully initialized.
|
|
27
|
+
* Be sure to check {@link DeepAR.isFootTrackingInitialized} before setting this callback.
|
|
28
|
+
* 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.
|
|
29
|
+
*/
|
|
30
|
+
onFootTrackingInitialized?: () => void;
|
|
31
|
+
/**
|
|
32
|
+
* Called when segmentation is fully initialized.
|
|
33
|
+
* Be sure to check {@link DeepAR.isSegmentationInitialized} before setting this callback.
|
|
34
|
+
* Because this callback is called only once. So if you set this callback after the segmentation is initialized, it will not be called again.
|
|
35
|
+
*/
|
|
36
|
+
onSegmentationInitialized?: () => void;
|
|
37
|
+
/**
|
|
38
|
+
* Called when the animation player transitions to a new state.
|
|
39
|
+
* @param newState Name of the new state that is being transitioned to.
|
|
40
|
+
*/
|
|
41
|
+
onAnimationTransitionedToState?: (newState: string) => void;
|
|
42
|
+
}
|
|
@@ -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,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Foot tracking initialization parameters.
|
|
3
|
+
*/
|
|
4
|
+
export interface DeepARFootTrackingConfig {
|
|
5
|
+
/**
|
|
6
|
+
* Path to the pose estimation wasm file, e.g. "/path/to/libPoseEstimation.wasm".
|
|
7
|
+
*/
|
|
8
|
+
poseEstimationWasmPath?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Path to the detector model, e.g. "/path/to/foot-detector-ios.bin".
|
|
11
|
+
*/
|
|
12
|
+
detectorPath?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Path to the tracker model, e.g. "/path/to/foot-tracker-ios.bin".
|
|
15
|
+
*/
|
|
16
|
+
trackerPath?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Path to the foot model object file, e.g. "/path/to/foot-model.obj".
|
|
19
|
+
*/
|
|
20
|
+
objPath?: string;
|
|
21
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parameters for the initialization of {@link DeepAR} object.
|
|
3
|
+
*/
|
|
4
|
+
export interface DeepARParams {
|
|
5
|
+
/**
|
|
6
|
+
* License key created on <a href="https://developer.deepar.ai/">DeepAR developer portal</a> for your web app.
|
|
7
|
+
*/
|
|
8
|
+
licenseKey: string;
|
|
9
|
+
/**
|
|
10
|
+
* Canvas element where DeepAR will render the camera and effects/filters.
|
|
11
|
+
*/
|
|
12
|
+
canvas: HTMLCanvasElement;
|
|
13
|
+
/**
|
|
14
|
+
* The URL of a DeepAR effect file. This effect will be applied when DeepAR is initialized.
|
|
15
|
+
* This parameter is optional. You can always later switch to a different effect with {@link DeepAR.switchEffect}.
|
|
16
|
+
*/
|
|
17
|
+
effect?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Path to the root directory of the DeepAR SDK. Most often this is used to provide the path to the root of the CDN that hosts the DeepAR SDK.
|
|
20
|
+
* For example "https://cdn.jsdelivr.net/npm/deepar@4.0.3/".<br>
|
|
21
|
+
*
|
|
22
|
+
* > ⚠️ <b>Be sure that the version of DeepAR js file and the root SDK path match!</b>
|
|
23
|
+
*
|
|
24
|
+
* This path will be used to locate and download all the additional needed files like ML models.
|
|
25
|
+
* DeepAR SDK can be hosted on any other server, but be sure not to change the directory and file structure of DeepAR SDK when hosing it.<br>
|
|
26
|
+
*
|
|
27
|
+
* To configure usage of non-default ML models, define them in the {@link additionalOptions}.
|
|
28
|
+
*/
|
|
29
|
+
rootPath?: string;
|
|
30
|
+
/**
|
|
31
|
+
* TODO
|
|
32
|
+
*/
|
|
33
|
+
additionalOptions?: {
|
|
34
|
+
/**
|
|
35
|
+
* By default, DeepAR preview will use the user facing camera. With these options you can disable the default camera usage or change the facing mode.
|
|
36
|
+
*/
|
|
37
|
+
cameraConfig?: {
|
|
38
|
+
/**
|
|
39
|
+
* Can be "user" or "environment". User will be a front facing camera on mobile devices, while environment will be the back facing camera.
|
|
40
|
+
*/
|
|
41
|
+
facingMode?: string;
|
|
42
|
+
/**
|
|
43
|
+
* If true, DeepAR will not use camera preview by default. You can use your own camera/video by calling {@link DeepAR.setVideoElement} or start the camera at any time by calling {@link DeepAR.startCamera}
|
|
44
|
+
*/
|
|
45
|
+
disableDefaultCamera?: boolean;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Provide a hint or hints to DeepAR to optimize the SDK in some scenarios. <br><br>
|
|
49
|
+
* Available hints:
|
|
50
|
+
* <ul>
|
|
51
|
+
* <li><b>face</b> - Will initialize face tracking as soon as possible. Without this hint face tracking is lazy loaded when some face tracking effect is loaded.</li>
|
|
52
|
+
* <li><b>segmentation</b> - Will initialize segmentation as soon as possible. Without this hint segmentation is lazy loaded when some segmentation effect is loaded.</li>
|
|
53
|
+
* <li><b>foot</b> - Will initialize foot tracking as soon as possible. Without this hint foot tracking is lazy loaded when some foot tracking effect is loaded.</li>
|
|
54
|
+
* </ul>
|
|
55
|
+
*/
|
|
56
|
+
hint?: string | string[];
|
|
57
|
+
/**
|
|
58
|
+
* TODO
|
|
59
|
+
*/
|
|
60
|
+
faceTrackingConfig?: {
|
|
61
|
+
/**
|
|
62
|
+
* TODO
|
|
63
|
+
*/
|
|
64
|
+
modelPath: string;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Object containing configuration about the DeepAR segmentation which is used by background removal effects.
|
|
68
|
+
*/
|
|
69
|
+
segmentationConfig?: {
|
|
70
|
+
/**
|
|
71
|
+
* Path to the segmentation model. Something like "path/to/segmentation-192x192.bin".
|
|
72
|
+
*/
|
|
73
|
+
modelPath: string;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Object containing configuration for DeepAR foot tracking which is used for virtual shoe try on.
|
|
77
|
+
*/
|
|
78
|
+
footTrackingConfig?: {
|
|
79
|
+
/**
|
|
80
|
+
* Path to the pose estimation wasm file, e.g. "/path/to/libPoseEstimation.wasm".
|
|
81
|
+
*/
|
|
82
|
+
poseEstimationWasmPath?: string;
|
|
83
|
+
/**
|
|
84
|
+
* Path to the detector model, e.g. "/path/to/foot-detector-ios.bin".
|
|
85
|
+
*/
|
|
86
|
+
detectorPath?: string;
|
|
87
|
+
/**
|
|
88
|
+
* Path to the tracker model, e.g. "/path/to/foot-tracker-ios.bin".
|
|
89
|
+
*/
|
|
90
|
+
trackerPath?: string;
|
|
91
|
+
/**
|
|
92
|
+
* Path to the foot model object file, e.g. "/path/to/foot-model.obj".
|
|
93
|
+
*/
|
|
94
|
+
objPath?: string;
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Path to deepar.wasm file. Something like "path/to/deepar.wasm".
|
|
98
|
+
*/
|
|
99
|
+
deeparWasmPath?: string;
|
|
100
|
+
};
|
|
101
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @internal
|
|
3
|
+
* Enum that defines possible types of logging messages.
|
|
4
|
+
*/
|
|
5
|
+
export declare enum LogType {
|
|
6
|
+
/**
|
|
7
|
+
* Information logging message.
|
|
8
|
+
*/
|
|
9
|
+
INFO = 1,
|
|
10
|
+
/**
|
|
11
|
+
* Warning logging message.
|
|
12
|
+
*/
|
|
13
|
+
WARNING = 2,
|
|
14
|
+
/**
|
|
15
|
+
* Error logging message.
|
|
16
|
+
*/
|
|
17
|
+
ERROR = 3
|
|
18
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
declare const gui: boolean;
|
|
2
|
+
declare const terminal: boolean;
|
|
3
|
+
declare const node: boolean;
|
|
4
|
+
declare global {
|
|
5
|
+
interface Window {
|
|
6
|
+
MSStream: any;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
declare const android: boolean;
|
|
10
|
+
declare const chromeos: boolean;
|
|
11
|
+
declare const tizen: boolean;
|
|
12
|
+
declare const ios: boolean;
|
|
13
|
+
declare const linuxBased: boolean;
|
|
14
|
+
declare const windows: boolean;
|
|
15
|
+
declare const macos: boolean;
|
|
16
|
+
declare const linux: boolean;
|
|
17
|
+
export { gui, terminal, node, android, chromeos, tizen, ios, linuxBased, windows, macos, linux, };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Describes the touch/click type.
|
|
3
|
+
*/
|
|
4
|
+
export declare enum ARTouchType {
|
|
5
|
+
/**
|
|
6
|
+
* Touch started.
|
|
7
|
+
*/
|
|
8
|
+
Start = 0,
|
|
9
|
+
/**
|
|
10
|
+
* Touch is pressed and is being moved.
|
|
11
|
+
*/
|
|
12
|
+
Move = 1,
|
|
13
|
+
/**
|
|
14
|
+
* Touch ended.
|
|
15
|
+
*/
|
|
16
|
+
End = 2
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Information about the touch. Used by {@link DeepAR.touchOccurred}.
|
|
20
|
+
*/
|
|
21
|
+
export interface ARTouchInfo {
|
|
22
|
+
/**
|
|
23
|
+
* X coordinate.
|
|
24
|
+
*/
|
|
25
|
+
x: number;
|
|
26
|
+
/**
|
|
27
|
+
* Y coordinate
|
|
28
|
+
*/
|
|
29
|
+
y: number;
|
|
30
|
+
/**
|
|
31
|
+
* Touch type.
|
|
32
|
+
*/
|
|
33
|
+
touchType: ARTouchType;
|
|
34
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parameters that specify the format of recorded videos. Used by {@link DeepAR.startVideoRecording}.
|
|
3
|
+
*/
|
|
4
|
+
export interface VideoRecordingOptions {
|
|
5
|
+
/**
|
|
6
|
+
* A MIME type specyfing the format for the resulting video, such as `video/webm` or `video/mp4`.
|
|
7
|
+
* Corresponds to the MIME type used by <a href="https://developer.mozilla.org/en-US/docs/Web/API/Blob">Blob</a>
|
|
8
|
+
* objects and <a href="https://developer.mozilla.org/en-US/docs/Web/API/MediaRecorder">MediaRecorder</a>
|
|
9
|
+
* from the MediaStream Recording API.
|
|
10
|
+
*
|
|
11
|
+
* Note that `video/mp4` may not be supported in all browsers.
|
|
12
|
+
*/
|
|
13
|
+
mimeType?: string;
|
|
14
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './version';
|
|
2
|
+
export * from './DeepAR';
|
|
3
|
+
export * from './initParams';
|
|
4
|
+
export * from './callbacks';
|
|
5
|
+
export * from './footTrackingConfig';
|
|
6
|
+
export * from './faceData';
|
|
7
|
+
export * from './footData';
|
|
8
|
+
export * from './videoRecordingOptions';
|
|
9
|
+
export * from './touchType';
|
|
10
|
+
export * from './logType';
|
package/package.json
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "deepar",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0-alpha-1",
|
|
4
4
|
"description": "The official DeepAR Web SDK",
|
|
5
5
|
"main": "js/deepar.esm.js",
|
|
6
|
-
"
|
|
6
|
+
"jsdelivr": "js/deepar.js",
|
|
7
|
+
"typings": "js/types/index.d.ts",
|
|
7
8
|
"keywords": [
|
|
8
9
|
"deepar",
|
|
9
10
|
"web",
|
|
10
11
|
"sdk",
|
|
11
12
|
"ar",
|
|
12
|
-
"effects"
|
|
13
|
+
"effects",
|
|
14
|
+
"bacground removal",
|
|
15
|
+
"bacground replacement",
|
|
16
|
+
"background blur",
|
|
17
|
+
"shoe try-on",
|
|
18
|
+
"AR mini-games"
|
|
13
19
|
],
|
|
14
20
|
"author": "deepar",
|
|
15
21
|
"license": "SEE LICENSE IN LICENSE.txt"
|
package/wasm/deepar.wasm
CHANGED
|
Binary file
|