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) | 1-to-1 call: 0.8 Group call: 0.9 |
For iOS apps, the virtual background feature is compatible with the following devices and operating system versions:
- iPhone 12 and newer models, running iOS 15 or later
Applying the virtual background effect increases CPU usage.
Overview
The PlanetKitCamera
class provides APIs for the virtual background feature. You can use the APIs on the singleton instance, PlanetKitCamera.instance
.
Set a blurred background
To apply a blur effect to the background, call the setVirtualBackgroundWithBlur()
method.
int radius = 15;
PlanetKitCamera.instance.setVirtualBackgroundWithBlur(radius)
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 string of image URI as an argument.
String fileUri = "URI_TO_IMAGE";
PlanetKitCamera.instance.setVirtualBackgroundWithImage(fileUri)
Clear the virtual background
To clear the virtual background, call the clearVirtualBackground()
method.
PlanetKitCamera.instance.clearVirtualBackground()
Related API
APIs related to the virtual background function are as follows.