Facial Comparison

Declaration

func compareFaces(
    _ target: UIImage, 
    _ faces: [UIImage], 
    success: SybrinBiometrics.facialComparisonSuccessCallbackType? = nil, 
    failure: SybrinBiometrics.failureCallbackType? = nil
)

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

Handling the success or failure callbacks are optional but recommended.

Calling the function

Parameters

Type

Description

UIImage

The target image that you would like to compare against.

[UIImage]

An array of the faces you would like to individually compare against the target.

Please ensure that all the images conform to our guidelines and that only one face is visible per image.

The target parameter is the image that contains the face you wish to run comparison on. The faces parameter is an array of images that contains faces, that the target will be compared to. For a visual understanding refer to the below figure.

Handling callback responses

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 comparison session.

Example:

success: { (model) in
    print("Facial comparison finished. We are \(model.averageConfidence * 100)% sure the faces match the target")
}

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 comparison failed because \(message)")
}

Full Example

let target = UIImage(named: "MyTargetImage")
let faces = [UIImage(named: "MyFace1Image"), UIImage(named: "MyFace2Image")]

SybrinBiometrics.shared.compareFaces(target, faces) { (model) in
    print("Facial comparison finished. We are \(model.averageConfidence * 100)% sure the faces match the target")
} failure: { (message) in
    print("Facial comparison failed because \(message)")
}

Last updated