enableVirtualBackground abstract method

Future<void> enableVirtualBackground(
  1. bool enabled,
  2. VirtualBackgroundSource backgroundSource
)

Enables/Disables the virtual background. (beta feature) The virtual background function allows you to replace the original background image of the local user or to blur the background. After successfully enabling the virtual background function, all users in the channel can see the customized background. You can find out from the virtualBackgroundSourceEnabled callback whether the virtual background is successfully enabled or the cause of any errors. Enabling the virtual background function involves a series of method calls. The calling sequence is as follows: Call (agora_segmentation, PortraitSegmentation, true) to enable the extension. Call enableVideo to enable the video module. Call this method to enable the virtual background function. Before calling this method, ensure that you have integrated the dynamic library. Android: libagora_segmentation_extension.so iOS: AgoraVideoSegmentationExtension.xcframework Call this method after enableVideo . This function requires a high-performance device. Agora recommends that you use this function on devices with the following chips: Snapdragon 700 series 750G and later Snapdragon 800 series 835 and later Dimensity 700 series 720 and later Kirin 800 series 810 and later Kirin 900 series 980 and later Devices with an A9 chip and better, as follows: iPhone 6S and later iPad Air 3rd generation and later iPad 5th generation and later iPad Pro 2nd generation and later iPad mini 5th generation and later Agora recommends that you use this function in scenarios that meet the following conditions: A high-definition camera device is used, and the environment is uniformly lit. There are few objects in the captured video. Portraits are half-length and unobstructed. Ensure that the background is a solid color that is different from the color of the user's clothing.

Param enabled Whether to enable virtual background: true: Enable virtual background. false: Disable virtual background.

Param backgroundSource The custom background image. See VirtualBackgroundSource for details. To adapt the resolution of the custom background image to that of the video captured by the SDK, the SDK scales and crops the custom background image while ensuring that the content of the custom background image is not distorted.

Implementation

Future<void> enableVirtualBackground(
    bool enabled, VirtualBackgroundSource backgroundSource);