バーチャル背景
ビデオ通話中にバーチャル背景(virtual background)機能を使用して、背景をぼかしたり画像に置き換えたりすることができます。ここでは、バーチャル背景機能の使い方について説明します。
対応する通話タイプ | SDKの最低バージョン |
---|---|
1対1通話、グループ通話(カンファレンス) | PlanetKit 5.4 |
Warning
バーチャル背景効果を適用すると、CPU使用率が増加します。
概要
PlanetKitPluginVirtualBackground
インターフェースでバーチャル背景機能のためのAPIを提供します。バーチャル背景機能用のAPIを使用するには、次の手順に従います。
PlanetKitPluginProviderVirtualBackground.getPlugin()
を使ってPlanetKitPluginVirtualBackground
オブジェクトを取得します。PlanetKitCameraManager
のsetVirtualBackgroundPlugin()
を使用して、カメラ管理モジュールにPlanetKitPluginValBackground
オブジェクトを設定します。
val plugin = PlanetKitPluginProviderVirtualBackground.getPlugin()
PlanetKit.getCameraManager().setVirtualBackgroundPlugin(plugin)
ぼかし背景を設定する
背景にぼかし(blur)効果を適用するには、setVirtualBackgroundWithBlur()
メソッドを呼び出します。
plugin.setVirtualBackgroundWithBlur()
setVirtualBackgroundWithBlur()
メソッドには、バーチャル背景に適用するガウスぼかし(Gaussian blur)の半径を定めるためのradius
を引数として渡すことができます。radius
は1から25までの値に設定でき、デフォルトは15です。radius
が大きいほど結果はぼやけます。
画像を背景に設定する
背景を画像に置き換えるには、Bitmap
画像を引数としてsetVirtualBackgroundWithImage()
メソッドを呼び出します。
val backgroundImage: Bitmap
plugin.setVirtualBackgroundWithImage(backgroundImage)
バーチャル背景タイプを確認する
現在使用中のバーチャル背景のタイプを確認するには、getCurrentVirtualBackgroundType()
メソッドを呼び出します。返却されるVirtualBackgroundType
はNONE
、BLUR
、IMAGE
のいずれかです。
val backgroundType = plugin.getCurrentVirtualBackgroundType()
バーチャル背景を解除する
バーチャル背景を解除するには、clearVirtualBackground()
メソッドを呼び出します。
plugin.clearVirtualBackground()
関連API
バーチャル背景機能に関連するAPIは次のとおりです。
-
PlanetKitPluginProviderVirtualBackground
-
PlanetKitPluginProviderVirtualBackground
のgetPlugin()
-
PlanetKitCameraManager
のsetVirtualBackgroundPlugin()
-
PlanetKitPluginVirtualBackground
-
setVirtualBackgroundWithBlur()
-
setVirtualBackgroundWithImage()
-
getCurrentVirtualBackgroundType()
-
clearVirtualBackground()
-
PlanetKitPluginVirtualBackground.VirtualBackgroundType