Effect loading(progress, finish, abort, error) events handler. Sent to BanubaSDKResourseLoader.
(String)
effect name
const handler = new BanubaSDKLoadResourceHandler("effectName")
.setFinishListener((event, xhr) => console.log("LOADED"))
.setProgressListener((event, xhr) => console.log("IN PROGRESS"))
.setAbortListener((event, xhr) => console.log("ABORTED"))
.setErrorListener((event, xhr) => console.error("ERROR"));
BanubaSDK.fetchEffect(handler);
Called while effect loading in progress.
(ProgressEvent)
EventListener event
(XMLHttpRequest)
XMLHttpRequest object
(Number)
effect directory size
Called after effect loaded.
(ProgressEvent)
EventListener event
(XMLHttpRequest)
XMLHttpRequest object
Called on effect loading error.
(ProgressEvent)
EventListener event
(XMLHttpRequest)
XMLHttpRequest object
Called on effect loading error.
(ProgressEvent)
EventListener event
(XMLHttpRequest)
XMLHttpRequest object
SDK API Manager.
(Object)
BanubaSDKManager configuration options
Name | Description |
---|---|
config.canvas HTMLElement
|
webgl2Canvas |
config.clientToken String
|
Banuba client token |
config.cameraOrientation Number
(default 0 )
|
camera orientation in degrees. can be 0,90,180,270 (counterclockwise) |
config.enableMirroring Boolean
(default true )
|
enable vertical mirroring for renderind (selfie mode) |
config.statusCallback Function?
|
status change event listener callback |
config.fpsUpdateCallback Function?
|
fps change event listener callback |
config.locateFile Function?
|
.wasm and .data file locator @see https://emscripten.org/docs/porting/files/packaging_files.html#changing-the-data-file-location |
const BanubaSDK = new BanubaSDKManager(canvas);
Set sdk load status changing event listener callback.
(Function)
sdk load status changing event listener callback
BanubaSDKManager
:
current context
BanubaSDK.setStatusListener((function(sdk) {
return function(data) {
const statusElement = document.getElementById('status');
const progressElement = document.getElementById('progress');
const spinnerElement = document.getElementById('spinner');
if (!data.isLoaded) {
progressElement.value = data.currentProgress;
progressElement.max = data.dataSize;
progressElement.hidden = false;
spinnerElement.hidden = false;
statusElement.innerHTML = `Downloading...(${data.currentProgress}/${data.dataSize})`;
} else {
progressElement.value = data.dataSize;
progressElement.max = data.dataSize;
progressElement.hidden = true;
spinnerElement.hidden = true;
sdk.canvas.hidden = false;
if (statusElement) {
statusElement.style.visibility = "hidden";
}
}
}
})());
Set sdk initialized event listener callback.
(Function)
sdk initialized event listener callback
BanubaSDKManager
:
current context
Sets update fps event listener callback.
(Function)
update fps event listener callback
BanubaSDKManager
:
current context
BanubaSDK.setFPSUpdateListener(currFps => console.log(curFps));
Try to initialize sdk.
BanubaSDK.init();
Destroy SDK
BanubaSDK.destroy();
Change active canvas for drawing
(HTMLElement)
new surface for drawing
BanubaSDKManager
:
current context
BanubaSDK.changeCanvas(canvas);
Loads and apply effect to webcam stream. Effect data should be fetched from server.
(String)
effect name
BanubaSDKManager
:
current context
BanubaSDK.loadEffect("effectName");
Unload current effect. Enable clean camera stream without effects.
BanubaSDKManager
:
current context
BanubaSDK.unloadEffect();
Fetch effect data from server.
(SDKLoadResourceHandler)
load effect handler
BanubaSDKManager
:
current context
const handler = new BanubaSDKLoadResourceHandler("effectName")
.setFinishListener((event, xhr) => console.log("LOADED"))
.setProgressListener((event, xhr) => console.log("IN PROGRESS"))
.setAbortListener((event, xhr) => console.log("ABORTED"))
.setErrorListener((event, xhr) => console.error("ERROR"));
BanubaSDK.fetchEffect(handler);
Calls native method, wich process frame.
(ImageData)
width, height, pixel colors of image
BanubaSDKManager
:
current context
BanubaSDK.processFrame(this.webcamHandler.getFrame());
Updates effect properties.
(String)
propertie name
BanubaSDKManager
:
current context
Call method in current effect.
BanubaSDKManager
:
current context
Calls native wasm method, wich starts webcamera playback.
BanubaSDKManager
:
current context
BanubaSDK.play();
Calls native wasm method, wich pause webcamera playback.
BanubaSDKManager
:
current context
BanubaSDK.pause();
Sets effect volume value.
(Number)
volume value
[0.0..1.0]
BanubaSDKManager
:
current context
BanubaSDK.setVolume(0.7);
Set face search algorithm.
(Object)
algorithm for face search. Can be good, medium, fast
BanubaSDKManager
:
current context
BanubaSDK.setFaceSearchMode(BanubaSDK.face_search_mode.good);
Starts webcam playback loop.
BanubaSDKManager
:
current context.
BanubaSDK.startPlayback();
Enable debug rendering with direct access to recognizer.
(any)
any
:
nothing.
BanubaSDK.enableDebug(true);
Help class in copies of which wasm native code sets user webcam video data.
Webcamera video handler.
(BanubaSDKManager)
Returns current frame image data.
ImageData
:
ImageData
const webcam = new BanubaSDKWebcamVideoHandler(BanubaSDK);
let currFrame = webcam.getFrame();
BanubaSDK.processFrame(currFrame);
Loads user media data (webcam image, etc...).
const webcam = new BanubaSDKWebcamVideoHandler(BanubaSDK);
webcam.loadUserMedia();
Stops webcam recording video
Handle document page visibility.
(BanubaSDKManager)