License key created on DeepAR developer portal for your web app.
Optional previewHTML element where AR preview will be presented.
This is usually a div element which is used solely for AR preview. AR preview will fully occupy the previewElement's space. Therefore, position and size your previewElement according to your preferred AR preview dimensions.
NOTE: AR preview will adjust to the size of the previewElement if it changes.
The canvas element will be appended as child to the previewElement. If you wish to work with the canvas element directly and position and size it yourself then use canvas parameter instead.
⚠️ You must specify previewElement or canvas.
Optional effectThe URL of a DeepAR effect file. This effect will be applied when DeepAR is initialized. This parameter is optional. You can always later switch to a different effect with switchEffect.
Optional rootPath to the root directory of the DeepAR SDK. This path will be used to locate and download all the additional needed files like ML models and wasm files.
By default, this points to the JsDelivr CDN. For example "https://cdn.jsdelivr.net/npm/deepar@5.0.0/".
If you want to host the DeepAR SDK yourself set the path to it here. It is recommended to host DeepAR SDK on your own since then you can use compressions like gzip and brotli on the files.
⚠️ Be sure that the version of DeepAR js file and the root SDK path match!
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.
To configure usage of non-default ML models, define them in the additionalOptions.
Optional canvasCanvas element where DeepAR will render the AR preview.
⚠️ You must specify previewElement or canvas.
The preferred way is by using the previewElement parameter. In that case, the DeepAR will take care of correctly sizing the canvas.
const canvas = document.createElement('canvas')
canvas.style.display = 'block'
// We want to fill the whole screen.
const width = window.innerWidth
const height = window.innerHeight
const dpr = window.devicePixelRatio || 1
canvas.width = width * dpr
canvas.height = height * dpr
canvas.style.width = `${width}px`
canvas.style.height = `${height}px`
Optional additionalAdditional DeepAR options.
Optional cameraCamera options. DeepAR will use the camera by default.
Optional disableIf true, DeepAR will not use camera preview by default and all the other options here are ignored in that case. You can use your own camera/video by calling setVideoElement or start the camera at any time by calling startCamera
Optional facingCan be "user" or "environment". User will be a front facing camera on mobile devices, while environment will be the back facing camera. Default is "user".
Optional rotation?: numberRotate the input camera. valid values: 0, 90, 180, 270.
Optional cameraCalled when the camera permission is asked.
Optional cameraCalled when the camera permission is granted.
Optional hint?: string | string[]Provide a hint or hints to DeepAR to optimize the SDK in some scenarios.
Available hints:
Optional faceFace tracking module path and options.
Path to the face tracking model. Something like "path/to/deepar/models/face/models-68-extreme.bin".
Optional rigidOptional posePath to the pose libPoseEstimation.wasm file, e.g. "/path/to/deepar/wasm/libPoseEstimation.wasm".
Optional detectorPath to the detector model, e.g. "/path/to/deepar/models/face-cnn/face-det.bin".
Optional trackerPath to the tracker model, e.g. "/path/to/deepar/models/face-cnn/face-track-19-v2.bin".
Optional objPath to the face model object file, e.g. "/path/to/deepar/models/face/face-rigid.obj".
Optional tfjsPath to tfjs-backend-wasm.wasm file, e.g. "path/to/deepar/wasm/tfjs-backend-wasm.wasm"
Optional tfjsPath to tfjs-backend-wasm-simd.wasm file, e.g. "path/to/deepar/wasm/tfjs-backend-wasm-simd.wasm"
Optional tfjsPath to tfjs-backend-wasm-threaded-simd.wasm file, e.g. "path/to/deepar/wasm/tfjs-backend-wasm-threaded-simd.wasm"
Optional faceOptional posePath to the pose libPoseEstimation.wasm file, e.g. "/path/to/deepar/wasm/libPoseEstimation.wasm".
Optional detectorPath to the detector model, e.g. "/path/to/deepar/models/face-cnn/face-det.bin".
Optional trackerPath to the tracker model, e.g. "/path/to/deepar/models/face-cnn/face-track.bin".
Optional objPath to the face model object file, e.g. "/path/to/deepar/models/face-cnn/face.obj".
Optional pdmPath to pdm zip, e.g. "/path/to/deepar/models/face-cnn/face-pdm.zip".
Optional tfjsPath to tfjs-backend-wasm.wasm file, e.g. "path/to/deepar/wasm/tfjs-backend-wasm.wasm"
Optional tfjsPath to tfjs-backend-wasm-simd.wasm file, e.g. "path/to/deepar/wasm/tfjs-backend-wasm-simd.wasm"
Optional tfjsPath to tfjs-backend-wasm-threaded-simd.wasm file, e.g. "path/to/deepar/wasm/tfjs-backend-wasm-threaded-simd.wasm"
Optional segmentationSegmentation module path and options.
Optional modelPath to the base segmentation model. Something like "path/to/deepar/models/segmentation/segmentation-192x192.bin". Thi is not used by default.
Optional mediaMediaPipe segmentation config.
Optional wasmBase path to wasm fileset. Something like "path/to/deepar/mediaPipe/segmentation/wasm".
Optional modelMediaPipe selfie segmenter model to be used. Something like "path/to/deepar/mediaPipe/segmentation/model/selfie_segmenter.tflite".
Optional deeparPath to deepar.wasm file. Something like "/path/to/deepar/wasm/deepar.wasm".
Optional dyPath to dyXzimgMagicFace.wasm file. Something like "/path/to/deepar/wasm/dyXzimgMagicFace.wasm".
Optional dyPath to dyArcoreScripting.wasm file. Something like "/path/to/deepar/wasm/dyArcoreScripting.wasm".
Optional dyPath to dyArcorePhysics.wasm file. Something like "/path/to/deepar/wasm/dyArcorePhysics.wasm".
Optional dynamicDynamic JS modules paths.
Optional xzimgPath to xzimg.js file. Something like "/path/to/deepar/js/dynamicModules/xzimg.js".
Optional mediaPath to mediaPipe.js file. Something like "/path/to/deepar/js/dynamicModules/mediaPipe.js".
Optional embeddedEmbedded DeepAR effect files paths.
Optional backgroundPath to background_blur.deepar file. Something like "/path/to/deepar/effects/background_blur.deepar".
Optional backgroundPath to background_replacement.deepar file. Something like "/path/to/deepar/effects/background_replacement.deepar".
Optional defaultPath to the default_envmap.webp file.
Optional customPath to some custom environment map effect should be rendered with. Internally, it is going to fetch the map and call setEnvironementMap.
Optional exposure?: numberTone mapping exposure.
Optional envEnvironment map intensity.
Optional toneTone mapping.
Optional pixelPixel ratio used for scaling the canvas. By default, SDK uses min(window.devicePixelRatio, 2).
Generated using TypeDoc
Parameters for the initialization of DeepAR object.