Unique customer identifier provided by SDK vendor.
A callback is fired when the SDK is ready for frame processing. Effects configuration should only be applied after this callback has been triggered.
Preload ML resources and put it to named cache. Will preload all required models files based on the sdk.config(). Could be used on the app initialisation. Will speed up future SDK initialization.
pass true to delete cache objects
Ability to configure sdk execution environment
configuration object
General configuration options
config = {
api_url: 'url', // Enable custom URL configuration for SDK authentication, suitable for on-premises solutions.
model_url: 'url', // Custom URL for the segmentation model; in most cases, this parameter does not require configuration.
sdk_url: 'url', // This parameter specifies the URL to the SDK folder for cases where you host the model files yourself.
preset: 'balanced', // You can set the default segmentation preset to one of the following options: quality, balanced, speed, or lightning.
proxy: true/false, // The configuration specifies whether segmentation should operate in a separate worker thread (not in the main UI thread), with the default value set to true.
provider: wasm/webgpu/auto, // Allow users to select where to execute the segmentation. In auto mode, the SDK will verify the availability of a GPU. If a GPU is not available, it will automatically fall back to using WASM
stats: true/false, // To enable or disable the sending of statistics.
models: {
'colorcorrector': 'url', // The feature allows for the provision of a custom model name; if left empty, the feature will be disabled.
'facedetector': 'url', // The feature allows for the provision of a custom model name; if left empty, the feature will be disabled.
'lowlighter': 'url', // The feature allows for the provision of a custom model name; if left empty, the feature will be disabled.
},
wasmPaths: { // Currently, WASM files are loaded from the same directory where the SDK is placed, but custom URLs are also supported (for example, you can load them from CDNs).
'ort-wasm.wasm': 'url',
'ort-wasm-simd.wasm': 'url',
'ort-wasm-threaded.wasm': 'url',
'ort-wasm-simd-threaded.wasm': 'url'
}
}
Example of how to change default segmentation preset
config = {
preset: 'lightning'
}
Example of how to disable colorcorrection and facedetection
config = {
models: {
'colorcorrector': '',
'facedetector': '',
'lowlighter': ''
}
}
Example of how to hot models on custom domain
config = {
sdk_url: 'https://domain.com/sdk/' // in this derectory should be subfolder models with all required models
}
Set media source of the background. Video sources will be played automatically from the beginning.
the link to image/video of the server or one of the following objects: MediaStream, MediaStreamTrack, HTMLVideoElement, ImageBitmap, Canvas.
Set the layout with custom params
objects with the custom params
Optional
size?: numberOptional
xOptional
ypersent = {
xOffset?: number, // horizontal offset relative to center, value can be a number from -1 to 1
yOffset?: number, // vertical offset relative to center, value can be a number from -1 to 1
size?: number, mask size percentage// value can be a number from 0 to 1 *
}
Set the layout mode. You can disable segmentation and show full camera frame or hide camera frame.
could be the one of the following: 'segmentation' | 'full' | 'hide' | 'transparent' Segmentation - Process the segmentation and display the selected background. Full - Show the full original frame without segmentation. Hide - Hide the original frame completely (only the background will be visible). Transparent - Process the segmentation and return the segmented person with a transparent background.
Set the segmentation mode. Segmentation mode allow to choose combination of quality and speed of segmentation. Balanced mode is enabled by default.
in string format. The values could be quality, balanced, speed, lightning.
Initiation of main SDK instance.