이 페이지는 현재 영어로만 제공되며 한국어 버전은 곧 제공될 예정입니다. 기다려 주셔서 감사드립니다.

Virtual Background

Accurately removes the background in real time and applies a virtual background (customizable):


iOS API Use

Integration guide for iOS

For directions on how to integrate the Tencent Effect SDK for iOS, see the integration guide for iOS.

Setting a virtual background

NSString *motionSegResPath = [[NSBundle mainBundle] pathForResource:@"segmentMotionRes" ofType:@"bundle"];//The absolute path of the `segmentMotionRes` folder
NSString *propertyType = @"motion"; //Set the effect type
NSString *propertyName = @"video_segmentation_blur_75"; //Specify the effect name
NSString *propertyValue = motionSegResPath; //Set the path of the animated effect
NSDictionary *dic = @{@"bgName":@"BgSegmentation.bg.png", @"bgType":@0, @"timeOffset": @0},@"icon":@"segmentation.linjian.png"};//Configure the reserved parameter
[self.beautyKit configPropertyWithType:propertyType withName:propertyName withData:propertyValue withExtraInfo:dic];

Setting a custom background

NSString *motionSegResPath = [[NSBundle mainBundle] pathForResource:@"segmentMotionRes" ofType:@"bundle"];//The absolute path of the `segmentMotionRes` folder
NSString *propertyType = @"motion"; //Set the effect type
NSString *propertyName = @"video_empty_segmentation"; //Specify the effect name
NSString *propertyValue = motionSegResPath; //Set the path of the animated effect
NSString *imagePath = @"/var/mobile/Containers/Data/Application/06B00BBC-9060-450F-8D3A-F6028D185682/Documents/MediaFile/image.png"; //The absolute path of the background image or video (after compression)
int bgType = 0;//The background type. 0: image; 1: video
int timeOffset = 0//The duration. If an image is used as the background, its value is 0; if a video is used, its value is the video length.
NSDictionary *dic = @{@"bgName":imagePath, @"bgType":@(bgType), @"timeOffset": @(timeOffset)},@"icon":@"segmentation.linjian.png"};//Configure the reserved parameter
[self.beautyKit configPropertyWithType:propertyType withName:propertyName withData:propertyValue withExtraInfo:dic];

Android API Use

Integration guide for Android

For directions on how to integrate the Tencent Effect SDK for Android, see the integration guide for Android.

Attribute setting API

void updateProperty(XmagicProperty<?> p)
Keying parameters:
Attribute Field
Description
category
Category.SEGMENTATION
ID
The resource folder name, which is required, such as video_segmentation_blur_45.
XmagicProperty.ID_NONE indicates there is no ID.
A custom keying ID must be XmagicConstant.SegmentationId.CUSTOM_SEG_ID.
resPath
Required. For more information, see the demo.
effkey
null (except for custom backgrounds). The value of a custom background is the selected resource path.
effValue
null

Setting a virtual background

// Initialize `XmagicProperty`
XmagicProperty xmagicProperty = new XmagicProperty(Category.SEGMENTATION,"video_segmentation_blur_45",resPath,null,null);
// Set the attributes
xmagicApi.updateProperty(xmagicProperty)

Setting a custom background

XmagicProperty xmagicProperty = new XmagicProperty(Category.SEGMENTATION,XmagicConstant.SegmentationId.CUSTOM_SEG_ID,resPath,null,null);

xmagicApi.updateProperty(xmagicProperty)