SFaceCompare: compare faces on your iOS device
SFaceCompare is a simple library for iOS to find and compare faces. SFaceCompare works on top of dlib and OpenCV libraries. With usage of trained model.
Features
- Face detecting / extracting
- Face aligment
- Face matching
Used Libraries
- dlib - Image processing
- openCV - Detecting face landmarks and face alignment
- SameFace - Core that connects dlib & openCV functionality under the hood
These libraries were used to create SameFace.framework which src on CVDlibUtils branch
Example
To run the example project, clone the repo, and run pod install
from the Example directory first.
Installation
Import Faces.mlmodel
Make import of Faces.mlmodel file into your actual project. To make this.
- Open Example App provided with this repo
- Find Faces.mlmodel
- Drag/Copy-Paste into root of your project
CocoaPods
CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:
$ gem install cocoapods
CocoaPods 1.1+ is required to build SFaceCompare.
To install library, simply add the following line to your Podfile:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '12.0'
use_frameworks!
target '<Your Target Name>' do
pod 'SFaceCompare'
end
Then, run the following command:
$ pod install
Usage Example
Faces are the same | Faces are different |
---|---|
AppDelegate.swift
In Your App delegate call SFaceCompare.opncvwrp.loadData() to load model related data. This Operation is long and async. So better put this before using methods from pod.
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
SFaceCompare.prepareData()
return true
}
As simple as possible
// 1: Create compare object
let faceComparator = SFaceCompare(on: image1, and: image2)
// 2: Call compareFaces method with success and error handlers
faceComparator.compareFaces{ results in ... }
Credits
SFaceCompare is owned and maintained by Bohdan Mihiliev & Anton Khrolenko
License
SFaceCompare is available under the MIT license. See the LICENSE file for more info.