VirtualBackgroundSource
自定义的背景。
public class VirtualBackgroundSource { public static final int BACKGROUND_NONE = 0; public static final int BACKGROUND_COLOR = 1; public static final int BACKGROUND_IMG = 2; public static final int BACKGROUND_BLUR = 3; public static final int BACKGROUND_VIDEO = 4; public static final int BLUR_DEGREE_LOW = 1; public static final int BLUR_DEGREE_MEDIUM = 2; public static final int BLUR_DEGREE_HIGH = 3; public int backgroundSourceType; public int color; public String source = null; public int blurDegree; public VirtualBackgroundSource( int backgroundSourceType, int color, String source, int blurDegree) { this.backgroundSourceType = backgroundSourceType; this.color = color; this.source = source; this.blurDegree = blurDegree; } public VirtualBackgroundSource() { this.backgroundSourceType = BACKGROUND_COLOR; this.color = 0xffffff; this.source = ""; this.blurDegree = BLUR_DEGREE_HIGH; } }
属性
- backgroundSourceType
- 自定义的背景。
- BACKGROUND_NONE(0):将背景处理为 alpha 信息,不进行替换,仅分割人像和背景。设置后,你可以调用 startLocalVideoTranscoder,实现人像画中画的效果。
- BACKGROUND_COLOR(1):(默认)背景为纯色。
- BACKGROUND_IMG(2):背景为 PNG、JPG 格式的图片。
- BACKGROUND_BLUR(3):背景为虚化处理后的背景。
- BACKGROUND_VIDEO(4):背景为 MP4、AVI、MKV、FLV 等格式的本地视频。
- color
- 自定义的背景图颜色。格式为 RGB 定义下的十六进制整数,不要带 # 号,如 0xFFB6C1 表示浅粉色。 默认值为 0xFFFFFF,表示白色。 取值范围为 [0x000000,0xffffff]。如果取值非法,SDK 会用白色背景图替换原背景图。
注意: 该参数仅在自定义背景图类型为 BACKGROUND_COLOR 时生效。
- source
- 自定义背景图的本地绝对路径。支持 PNG 和 JPG 格式。如果路径无效,SDK 会用白色背景图替换原背景图。
注意: 该参数仅在自定义背景图类型为 BACKGROUND_IMG 时生效。
- blurDegree
- 自定义背景图的模糊程度。
- BLUR_DEGREE_LOW(1):自定义背景图的虚化程度为低。用户差不多能看清背景。
- BLUR_DEGREE_MEDIUM(2):自定义背景图的虚化程度为中。用户较难看清背景。
- BLUR_DEGREE_HIGH(3):(默认)自定义背景图的虚化程度为高。用户很难看清背景。
注意: 该参数仅在自定义背景图类型为 BACKGROUND_BLUR 时生效。