BackgroundFilterProcessor

public class BackgroundFilterProcessor

BackgroundFilterProcessor is a processor that uses SegmentationProcessor to process a frame by creating the alpha mask of the foreground image and blending the mask with the input image which is then rendered on top of a background image.

  • Static method to check whether BackgroundFilterProcessor can be used. This verifies that the builder has linked the necessary runtime framework (i.e. AmazonChimeSDKMachineLearning) to use this class.

    Declaration

    Swift

    public static func isAvailable() -> Bool

    Return Value

    true if the class can be used, otherwise false.

  • Public constructor to initialize the processor.

    Declaration

    Swift

    public init(logger: Logger)

    Parameters

    logger

    Custom logger to log events.

  • Creates the alpha mask [0-255] of the foreground image using SegmentationProcessor.

    Declaration

    Swift

    public func createForegroundAlphaMask(inputFrameCG: CGImage,
                                          inputFrameCI: CIImage) -> CIImage?

    Parameters

    inputFrameCG

    Input CGImage frame to produce the foreground image.

    inputFrameCI

    Input CIImage frame to produce the foreground image.

    Return Value

    Alpha mask CGImage of the foreground.

  • Blends foreground alpha mask with input image to produce a foreground image which is rendered on top of a background image using CIBlendWithAlphaMask CIFilter.

    Declaration

    Swift

    public func blendWithWithAlphaMask(inputFrameCI: CIImage,
                                       maskImage: CIImage,
                                       backgroundImage: CIImage) -> CIImage?

    Parameters

    inputFrameCI

    Input image which is used to blend the foreground alpha mask to produce the foreground image.

    maskImage

    Foreground alpha mask.

    backgroundImage

    Background image which can be a blurred or a custom background image.

  • Declaration

    Swift

    public func getBufferPool() -> CVPixelBufferPool?

    Return Value

    Buffer pool used to store the final image data.