The Virtual Background feature allows users to blur own Video Background or to use a image from Library as as Video Background. This feature works best with a physical green screen at your backdrop or with uniform lighting on a plain backdrop. In other cases, user may experience patchy edges.

Released: June 1, 2022

How to use Virtual Background SDK?

Follow these steps:

  • You get the .aar file after downloading the Virtual Background SDK.
  • You get the .aar file after downloading the Android SDK.
  • Add the downloaded .aar files under lib folder.
  • Go to your application’s build.gradle file and add the following code in the dependencies section:
implementation 'com.google.mlkit:segmentation-selfie:16.0.0-beta4'
implementation 'io.github.zncmn.libyuv:core:0.0.7'
implementation fileTree(dir: 'libs', include: ['.aar', '.jar'], exclude: [])

SDK Method & Callbacks

The EnxVirtualBackground.enableVirtualBackground() method is used to add Virtual Background to Local Stream. To use this method, you need create an instance of Class EnxVirtualBackground and pass it’s reference to the enableVirtualBackground() method.

Class: EnxVirtualBackground

Observerpublic void EnxVirtualBackgroundStateObserver(EnxVirtualBackgroundStateObserver-Object)

Method: public void enableVirtualBackground ( this, enxRoom)

Parameters:

  • this– This is the self instance reference.
  • enxRoom – This is the reference of EnxRoom Object.

Callbacks:

  • onAttachVirtualBackground– Callback when Virtual Background is attached to the Local Stream.
  • onDetachVirtualBackground – Callback when Virtual Background is detached from the Local Stream.
  • onVirtualBackgroundFailure – Callback when Virtual Background fails to attach with Local Stream.
// Initiate Object of EnxVirtualBackground
EnxVirtualBackground virtualBackground = new EnxVirtualBackground(); 

// Enable Virtual Background
virtualBackground.enableVirtualBackground(this, enxRoom);

// Set Observer
virtualBackground.SetEnxVirtualBackgroundStateObserver(this);


// Callback when Virtual Background is attached to the Local Stream.
@Override 
public void onAttachVirtualBackground(JSONObject jsonObject) { 

} 
 
// Callback when Virtual Background is detached from the Local Stream.
@Override 
public void onDetachVirtualBackground(JSONObject jsonObject) { 

} 
 
// Callback when Virtual Background fails to attach with Local Stream.
@Override 
public void onVirtualBackgroundFailure(JSONObject jsonObject) { 

}