Live face verification captures the user’s selfie for facial verification or any other purposes, after verifying the user’s physical presence in front of the device camera. The verification (using LiveFaceVerificationViewController
) is returned in a Selfie
object.
Ensure that you’ve added the UI library to your Podfile or View Controller. See Add the dependencies needed for your application for more information.
The LiveFaceVerificationViewController
class is a View Controller with configurable resources, a camera implementation, and other UI components that can be directly plugged into your app with a few lines of code.
Initialize LiveFaceVerificationViewController.Builder
with a completion block to receive the completion events with the result. For example:
class YourViewController: UIViewController {
override func viewDidAppear() {
super.viewDidAppear()
do {
try LiveFaceVerificationViewController.Builder { (isComplete, selfie) in
guard isComplete,
let selfie = selfie else {
// Canceled
return
}
// Handle Selfie here
}
.setAccuracy(accuracy: .low)
.setVerificationTime(verificationTime: 2.0)
.setVerificationSteps(verificationSteps: SCLiveFaceVerificationStep.lfv_smile, SCLiveFaceVerificationStep.lfv_straight_face)
.create().show(parentViewController: self)
} catch {
// Handle errors thrown by Builder here
}
}
}
verificationSteps
can be: .lfv_smile
, .lfv_straight_face
, lfv_close_left_eye
, or lfv_close_right_eye
.
verificationTime
must be greater than 0. The default value is 2.5 seconds.
The default value for accuracy
is SCLiveFaceVerificationAccuracy.medium
. This can also be: SCLiveFaceVerificationAccuracy.low
or ``SCLiveFaceVerificationAccuracy.high`.
You can initialize LiveFaceVerificationViewController
with the default values like this:
LiveFaceVerificationViewController.Builder { (isComplete, selfie) in
guard isComplete,
let selfie = selfie else {
// Canceled
return
}
// Handle Selfie here
}
.create().show(parentViewController: self)
By default, the SDK uses Apple’s CIDetector
to find faces in the image. If you want to use another face detector, you can implement SCFaceDetector
, and pass it to the Builder like this:
try? LiveFaceVerificationViewController.Builder(listener: self)
.setFaceDetector(faceDetector: YOUR_CUSTOM_FACE_DETECTOR)
.create()
.show(parentViewController: self)
In the SCFaceDetector
implementation, the resulting face objects must be converted to SCFace
when extending SCFaceDetector
.