Virtual background
In video calls, you can use the virtual background feature to either blur the background or replace it with an image. This page describes how to use the virtual background feature.
Supported call type | Minimum SDK version |
---|---|
1-to-1 call, group call (conference) | PlanetKit 5.4 |
Starting from PlanetKit 5.5.1, the PlanetKitPluginProviderVirtualBackground
class is provided as a separate plugin (plugin-virtualbackground
).
Applying the virtual background effect increases CPU usage.
Overview
The PlanetKitPluginVirtualBackground
class provides APIs for the virtual background feature. To use the APIs, do the following depending on the SDK version you're using.
PlanetKit 5.5.1 or higher
-
Add the following dependency in your
build.gradle
.implementation ('com.linecorp.planetkit:plugin-virtualbackground:1.0.0') {
exclude group: 'com.linecorp.planetkit', module: 'planetkit'
} -
Apply the virtual background plugin.
val plugin = PlanetKitPluginProviderVirtualBackground.getPlugin()
PlanetKit.getCameraManager().setVirtualBackgroundPlugin(plugin)
PlanetKit 5.5.0
Apply the virtual background plugin.
val plugin = PlanetKitPluginProviderVirtualBackground.getPlugin()
PlanetKit.getCameraManager().setVirtualBackgroundPlugin(plugin)
Set a blurred background
To apply a blur effect to the background, call the setVirtualBackgroundWithBlur()
method.
plugin.setVirtualBackgroundWithBlur()
The setVirtualBackgroundWithBlur()
method can accept radius
as an argument, which determines the radius for the Gaussian blur applied to the virtual background. The radius
can be set between 1 and 25, and its default value is 15. A larger radius
results in a blurrier result.
Set an image background
To replace the background with an image, call the setVirtualBackgroundWithImage()
method with a Bitmap
image as an argument.
val backgroundImage: Bitmap
plugin.setVirtualBackgroundWithImage(backgroundImage)
Get the virtual background type
To get the type of the virtual background currently in use, call the getCurrentVirtualBackgroundType()
method. This method returns a VirtualBackgroundType
, which can be NONE
, BLUR
, or IMAGE
.
val backgroundType = plugin.getCurrentVirtualBackgroundType()
Clear the virtual background
To clear the virtual background, call the clearVirtualBackground()
method.
plugin.clearVirtualBackground()
Related API
APIs related to the virtual background function are as follows.
-
PlanetKitPluginProviderVirtualBackground
-
getPlugin()
ofPlanetKitPluginProviderVirtualBackground
-
setVirtualBackgroundPlugin()
ofPlanetKitCameraManager
-
PlanetKitPluginVirtualBackground
-
setVirtualBackgroundWithBlur()
-
setVirtualBackgroundWithImage()
-
getCurrentVirtualBackgroundType()
-
clearVirtualBackground()
-
PlanetKitPluginVirtualBackground.VirtualBackgroundType