バーチャル背景
ビデオ通話中にバーチャル背景(virtual background)機能を使用して、背景をぼかしたり画像に置き換えたりすることができます。ここでは、バーチャル背景機能の使い方について説明します。
対応する通話タイプ | SDKの最低バージョン |
---|---|
1対1通話、グループ通話(カンファレンス) | PlanetKit 5.4 |
PlanetKit 5.5.1からPlanetKitPluginProviderVirtualBackground
クラスは、別途のプラグイン(plugin-virtualbackground
)として提供します。
バーチャル背景効果を適用すると、CPU使用率が増加します。
概要
PlanetKitPluginVirtualBackground
クラスは、バーチャル背景機能のためのAPIを提供します。バーチャル背景機能のためのAPIを使用するには、使用するSDKバージョンに応じて以下の手順に従ってください。
PlanetKit 5.5.1以上
-
build.gradle
ファイルに以下の従属性を追加してください。implementation ('com.linecorp.planetkit:plugin-virtualbackground:1.0.0') {
exclude group: 'com.linecorp.planetkit', module: 'planetkit'
} -
バーチャル背景プラグインを適用してください。
val plugin = PlanetKitPluginProviderVirtualBackground.getPlugin()
PlanetKit.getCameraManager().setVirtualBackgroundPlugin(plugin)
PlanetKit 5.5.0
バーチャル背景プラグインを適用します。
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