Skip to main content
Version: 5.5

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 typeMinimum SDK version
1-to-1 call, group call (conference)PlanetKit 5.4
Note

The virtual background feature is compatible with the following devices and operating system versions:

  • iOS: iPhone 12 and newer models, running iOS 15 or later
  • macOS: Apple desktops and laptops with an Apple silicon processor, running macOS 12 or later
Warning

Applying the virtual background effect increases CPU usage.

Overview

To use the virtual background feature, use the computed property PlanetKitCameraManager.shared.virtualBackground with the PlanetKitVirtualBackground class.

Set a blurred background

To apply a blur effect to the background, set PlanetKitCameraManager.shared.virtualBackground with the PlanetKitVirtualBackground(blurRadius:) method.

let blurRadius: Float
PlanetKitCameraManager.shared.virtualBackground = PlanetKitVirtualBackground(blurRadius: blurRadius)

The blurRadius parameter determines the radius for the Gaussian blur applied to the virtual background. The recommended default value for the blurRadius parameter is 15.0. A larger blurRadius results in a blurrier result.

Set an image background

To replace the background with an image, set PlanetKitCameraManager.shared.virtualBackground with the PlanetKitVirtualBackground(image:) method.

let uiImage = UIImage(named: "BackgroundImage")
let image = CIImage(image: uiImage)
PlanetKitCameraManager.shared.virtualBackground = PlanetKitVirtualBackground(image: image)

Get the virtual background type

The type of the virtual background currently in use can determined by PlanetKitCameraManager.shared.virtualBackground.type. The returned PlanetKitVirtualBackgroundType can be none, blur, or image.

let currentVirtualBackgroundType = PlanetKitCameraManager.shared.virtualBackground?.type ?? .none

Clear the virtual background

To clear the virtual background, set PlanetKitCameraManager.shared.virtualBackground to nil.

PlanetKitCameraManager.shared.virtualBackground = nil

APIs related to the virtual background function are as follows.

  • virtualBackground of PlanetKitCameraManager iOS, macOS
  • PlanetKitVirtualBackground iOS, macOS
  • PlanetKitVirtualBackgroundType iOS, macOS