虚拟背景
在直播、会议等场景实现虚拟背景,实时精准分割,支持自定义背景:


iOS 集成指引
方法
- (void)setEffect:(NSString * _Nullable)effectName effectValue:(int)effectValue resourcePath:(NSString * _Nullable)resourcePath extraInfo:(NSDictionary * _Nullable)extraInfo;
虚拟背景设置
NSString *path = [[[NSBundle mainBundle] pathForResource:@"segmentMotionRes" ofType:@"bundle"] stringByAppendingPathComponent:@"video_segmentation_blur_75"];[_xMagicKit setEffect:EFFECT_MOTION effectValue:0 resourcePath:path extraInfo:nil];
自定义背景设置
NSString *resourcePath = [[[NSBundle mainBundle] pathForResource:@"segmentMotionRes" ofType:@"bundle"] stringByAppendingPathComponent:@"video_empty_segmentation"];NSMutableDictionary *dic = [NSMutableDictionary dictionary];dic[@"segType"] = @"custom_background";dic[@"bgType"] = 0;//自定义背景的类型。 0表示图片,1表示视频dic[@"bgPath"] = @"/var/mobile/Containers/Data/Application/06B00BBC-9060-450F-8D3A-F6028D185682/Documents/MediaFile/image.png"; //自定义背景图片的绝对路径。如果自定义背景选择的是视频,需要对视频进行压缩转码处理,使用压缩转码处理后的绝对路径[_xMagicKit setEffect:EFFECT_SEGMENTATION effectValue:0 resourcePath:resourcePath extraInfo:dic];