Tests Cocoapods

Ver-ID Core

The Ver-ID Core framework does face detection, face recognition and user management. The default implementation uses Core Data to store user’s face templates.

Installation

To create Ver-ID environment you will need a valid Ver-ID SDK identity p12 file and a password for your app’s bundle ID. Please contact a member of the Applied Recognition team to obtain it or request an evaluation licence.

Once you obtain the p12 file and password for your app add the file to your project and enter the password to your app’s Info.plist file under the key com.appliedrec.verid.password:

<key>com.appliedrec.verid.password</key>
<string>[your password]</string>

Usage

The following example creates an instance of VerID and attempts to detect a face in an image.

import UIKit
import VerIDCore

class MyClass {

    func detectFaceInImage(_ image: CGImage, withOrientation orientation: CGImagePropertyOrientation, completion: (Result<RecognizableFace,Error>) -> Void) {
        // Create VerID image from the CGImage and orientation
        let verIDImage = VerIDImage(cgImage: image, orientation: orientation)
        // Create VerIDFactory instance
        let verIDFactory = VerIDFactory()
        // Here you can set the factory's faceDetectionFactory, faceRecognitionFactory or userManagementFactory properties if you don't wish to use the defaults
        // Set the factory's delegate, which will receive a callback if the VerID instance creation fails
        verIDFactory.delegate = self
        // Create an instance of VerID
        verIDFactory.createVerID { result in
            do {            
                let verID = try result.get()
                // Detect faces in the Ver-ID image
                let faces = try verID.faceDetection.detectFacesInImage(verIDImage, limit: 1, options: 0)
                if faces.isEmpty {
                    // No face detected in the image
                    throw FaceDetectionError.faceNotFound
                }
                // Convert faces to faces that can be used for face recognition
                let recognizableFaces = try verID.faceRecognition.createRecognizableFacesFromFaces(faces, inImage: verIDImage)
                guard let face = recognizableFaces.first else {
                    // This will not be reached as faces weren't empty
                    throw FaceRecognitionError.templateExtractionFailed
                }
                // Face can be used for face recognition
                completion(.success(face))
            } catch {
                // Face detection or recognition failed
                completion(.failure(error))
            }
        }
    }
}

API Reference Documentation