Basic SDK - iOS

Face Liveness Detection SDK

Features

License

We offer lifetime license(perpetual license) based on bundle ID for iOS SDKs. The license is available for a one-time payment. In other words, once you purchase license from me, you can use our SDK permanently.

To request a license, please contact us:

Email: contact@kby-ai.com

Telegram: @kbyai

WhatsApp: +19092802609

Skype: live:.cid.66e2522354b1049b

System Requirements

  • CPU: 2 cores or more

  • RAM: 100MB or more

  • OS: iOS 13.0 or later

  • Architecture: arm64-v8a

Setup

  1. Copy the SDK (facesdk.framework folder) to the root folder of your project.

  2. Add SDK framework to the project in Xcode.

Project Navigator -> General -> Frameworks, Libraries, and Embedded Content

  1. Add the bridging header to your project settings

Project Navigator -> Build Settings -> Swift Compiler - General

Initializing SDK

  1. Step one

  • To begin, you need to activate the SDK using the license that you have received.

FaceSDK.setActivation("...")
  • If activation is successful, the return value will be SDK_SUCCESS. Otherwise, an error value will be returned.

  1. Step Two

  • After activation, call the SDK's initialization function.

FaceSDK.initSDK()
  • If initialization is successful, the return value will be SDK_SUCCESS. Otherwise, an error value will be returned.

Enums and Classes

1. SDK_ERROR

This enumeration represents the return value of the 'initSDK' and 'setActivation' functions.

FeatureValueName

Successful activation or initialization

0

SDK_SUCCESS

License key error

-1

SDK_LICENSE_KEY_ERROR

AppID error (Not used in Server SDK)

-2

SDK_LICENSE_APPID_ERROR

License expiration

-3

SDK_LICENSE_EXPIRED

Not activated

-4

SDK_NO_ACTIVATED

Failed to initialize SDK

-5

SDK_INIT_ERROR

2. FaceBox

This class represents the output of the face detection function that contains the detected face rectangle, liveness score, and facial angles such as yaw, roll, and pitch.

FeatureTypeName

Face rectangle

int

x1, y1, x2, y2

Face angles (-45 ~ 45)

float

yaw, roll, pitch

Liveness score (0 ~ 1)

float

liveness

APIs

1. setActivation

To begin, you need to activate the SDK using the license that you have received.

var ret = FaceSDK.setActivation("...")

If activation is successful, the return value will be SDK_SUCCESS. Otherwise, an error value will be returned.

2. initSDK

After activation, call the SDK's initialization function.

ret = FaceSDK.initSDK()

If initialization is successful, the return value will be SDK_SUCCESS. Otherwise, an error value will be returned.

3. faceDetection

The SDK offers a single function for detecting face and liveness detection, which can be used as follows:

let faceBoxes = FaceSDK.faceDetection(image)
func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) { 
     
    guard let pixelBuffer: CVPixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer) else { return } 
     
    CVPixelBufferLockBaseAddress(pixelBuffer, CVPixelBufferLockFlags.readOnly) 
    let image = CIImage(cvPixelBuffer: pixelBuffer).oriented(CGImagePropertyOrientation.leftMirrored) 
    let capturedImage = UIImage(ciImage: image) 
    CVPixelBufferUnlockBaseAddress(pixelBuffer, CVPixelBufferLockFlags.readOnly) 
     
    let faceBoxes = FaceSDK.faceDetection(capturedImage) 
    DispatchQueue.main.sync { 
        self.faceView.setFrameSize(frameSize: capturedImage.size) 
        self.faceView.setFaceBoxes(faceBoxes: faceBoxes) 
    } 
} 

This function takes a single parameter, which is a UIImage object.

The return value of the function is a list of FaceBox objects.

Default Thresholds

let livenessThreshold = 0.7

If the liveness score exceeds 0.7, the face is a real face.

Last updated