FaceLivenessDetection is a Swift package that provides a framework for detecting face liveness using the front camera with depth data. The package uses AVFoundation and Vision frameworks to capture video and depth data, and perform face detection and liveness prediction.
- Face detection with depth data
- Real-time face orientation analysis
- Liveness prediction based on captured images
- Integration with SwiftUI and UIKit
liveness_v2_demo.MP4
struct ContentView: View {
var body: some View {
// Embedding the FaceLivenessDetectionView inside a your view.
FaceLivenessDetectionView(
timeInterval: 3, // Set the time interval for the fake progress UI.
onCompletion: handleCompletion // Your completion handler to process the result.
)
}
/// Handles the completion of the liveness detection.
/// - Parameter result: The result of the liveness detection, either successful with data or a failure with an error.
func handleCompletion(result: Result<LivenessDataModel, LivenessDetectionError>) {
switch result {
case .success(let dataModel):
print("Detection successful: \(dataModel)")
// Handle success case, update UI or data model accordingly.
case .failure(let error):
print("Detection failed with error: \(error)")
// Handle error, show alert or error message to the user.
}
}
}
- iOS 15.0+
- Xcode 15.0+
- Swift 5.0+
You can integrate FaceLivenessDetection into your project using Swift Package Manager. To add the package to your Xcode project, follow these steps:
- Open your Xcode project.
- Go to
File
>Add Packages
. - Enter the repository URL:
https://github.com/9count/FaceLivenessDetection
. - Choose the latest version or specify the version you need.
- Add the package to your project.