YotiFaceCapture provides a simplified way of capturing a face. It performs face detection from the front facing camera, analyses those frames and produces an optimised cropped image of the captured face.
- iOS 12.0+
- Swift 5.3+
Make sure you've installed and are running the latest version of:
Add the following to your Podfile
and run pod install
from its directory:
platform :ios, '12.0'
target 'TargetName' do
use_frameworks!
pod 'YotiFaceCapture'
end
Import the framework in your implementation:
import YotiFaceCapture
Fetch FaceCaptureViewController from framework and set delegate
let faceCaptureViewController = FaceCapture.faceCaptureViewController()
faceCaptureViewController.delegate = self
Start the camera feed
faceCaptureViewController.startCamera()
Start the analysis
faceCaptureViewController.startAnalyzing(withConfiguration: .default)
Whenever required, both camera feed and analysis process can be stopped
faceCaptureViewController.stopCamera()
faceCaptureViewController.stopAnalyzing()
Conform to FaceCaptureViewDelegate
func faceCapture(didTransitionToState state: FaceCaptureState) {
switch state {
case .success(.cameraReady):
break
case .success(.analyzing):
break
case .success(.cameraStopped):
break
case .failure(let error):
break
}
}
func faceCapture(originalImage: UIImage?, didResult result: FaceCaptureResult) {
switch result {
case .success(.validFrame(let information)):
break
case .failure(let error):
break
}
}
Provide a FaceCaptureConfiguration instance when calling the startAnalyzing method
let faceCaptureConfiguration = FaceCaptureConfiguration(scanningArea: view.frame,
imageQuality: .medium,
validationOptions: [.faceNotStraight])
faceCaptureViewController.startAnalyzing(withConfiguration: faceCaptureConfiguration)
The validation options available are:
case eyesNotOpen
case faceNotStraight
case faceNotStable(requiredFrames: Int)