PFCDynamic

public class PFCDynamic

Main Class containing PfC Dynamic functionality

  • Initialization does NOT guarantee that instance will work correctly. Use checkStatus() method to ensure that initialization was successful.

    Declaration

    Swift

    public init(apiKey: String, certificate: String)

    Parameters

    apiKey

    API key that comes with your license

    certificate

    Certificate that comes with your license

  • Use this method to ensure that initialization was successful.

    Return codes are:

    • 0: Success
    • -1: Expired certificate
    • -2: Wrong apikey/certificate combination
    • -3: Failed to init AI model
    • -4: Failed to load model file PFCDynamicModel.pnnc from framework resources
    • -5: Failed to create context

    Declaration

    Swift

    public func checkStatus() -> Int32

    Return Value

    0 if initialization succeeded. Any other value indicates an error.

  • This method can apply Dynamic to your image. Note that it might throw an error in some cases.

    Declaration

    Swift

    public func processImage(_ image: CGImage, strength: Float) throws -> CGImage

    Parameters

    image

    CGImage instance that contains your image

    strength

    Using values from 0 to 1, you can control Dynamic’s strength.

    Return Value

    Image with applied Dynamic effect.

  • You can control various parameter (e.g. deflickering) with this method. Setting parameters to any other value than 0 is recommended only if you’re working with videos or camera feed. Note that deflickering has a cumulative effect and in order to reset it you can call resetDeflicker() method.

    Declaration

    Swift

    public func setParams(deflickerCurve: Float, deflickerImage: Float, skip: Int)

    Parameters

    deflickerCurve

    Recommended value is 0.08

    deflickerImage

    Recommended value is 0.9

    skip

    Controls how many frames should be skipped before calculating inference again

  • Call this method to reset deflicker’s cumulative effect

    Declaration

    Swift

    public func resetDeflicker()