Facial Recognition

Declaration

func openFacialRecognition(
    on viewController: UIViewController, 
    for identifier: String, 
    doneLaunching: SybrinBiometrics.doneLaunchingType? = nil, 
    success: SybrinBiometrics.facialRecognitionSuccessCallbackType? = nil, 
    failure: SybrinBiometrics.failureCallbackType? = nil, 
    cancel: SybrinBiometrics.cancelCallbackType? = nil
)

To view all the type aliases, go to the SybrinBiometrics class

Handling the doneLaunching , success , failureor cancel callbacks are optional but recommended.

Calling the function

Parameters

Type

Description

UIViewController

The controller you would like to present on.

String

The identifier you would like to recognize the face for.

Sybrin does not provide user management for the identifiers you train and recognize on your license key. The proper management and storage of unique identifiers is the sole responsibility of you as the developer.

Handling callback responses

doneLaunching

The doneLaunching callback will be executed after the view controller has successfully launched, or if the view controller failed to launch.

Parameters:

Type

Description

Bool

true if the view controller presented successfully; otherwise, false.

String?

If an error occurs, a message describing the error; otherwise, nil.

Example:

doneLaunching: { (didLaunch, message) in
    if didLaunch {
        print("Launched successfully!")
    } else if let message = message {
        print("Failed to launch because \(message)")
    }
}

success

The success callback will be executed after the session has finished and the view controller has been dismissed.

Parameters:

Type

Description

An object containing the results of the facial recognition session.

Example:

success: { (model) in
    print("Facial recognition finished. We are \(model.confidence * 100)% sure you are \(identifier)")
}

failure

The failure callback will be executed after the session has failed and the view controller has been dismissed.

Parameters:

Type

Description

String

A message describing the error.

If you would like to report a bug, contact us!

Example:

failure: { (message) in
    print("Facial recognition failed because \(message)")
}

cancel

The cancel callback will be executed after the user has dismissed the view controller and before the session could finish.

Parameters:

None

Example:

cancel: {
    print("Facial recognition canceled")
}

Full Example

let identifier = "uniqueIdentifier"

SybrinBiometrics.shared.openFacialRecognition(on: self, for: identifier) 
{ (didLaunch, message) in
    if didLaunch {
        print("Launched successfully!")
    } else if let message = message {
        print("Failed to launch because \(message)")
    }
} success: { (model) in
    print("Facial recognition finished. We are \(model.confidence * 100)% sure you are \(identifier)")
} failure: { (message) in
    print("Facial recognition failed because \(message)")
} cancel: {
    print("Facial recognition canceled")
}

Last updated