Installation instructions

LunaCore.framework is distributed as part of the Luna SDK.

LunaCore is the main dependency in the Luna SDK and provides 3 public services:

  • LCBestShotDetectorProtocol
  • LCDescriptorExtractorProtocol
  • LCFaceDetectorProtocol

Luna SDK Build (if supplied with source code)

  • Install Xcode version 12.x (if not installed)
  • Start Terminal and go to the directory with the lunasdk-ios project
  • Run the script buildSDK.sh with the command sh buildSDK.sh
  • At the end of the building process, the directory LUNA_SDK will open in which all the assembled frameworks are located

LunaCore Integration

  • Open the LUNA_SDK folder and drag LunaCore.framework,fsdk.framework, tsdk.framework and flower.framework into the Frameworks, Libraries, and Embedded Content group of your project (make sure the frameworks are marked asEmbed & Sign)

License Activation


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    LCLunaConfiguration.activateLicense()

    return true
}

Using LCBestShotDetectorProtocol

LCBestShotDetectorProtocol allows you to get the best face shot from the video stream.

  • Import the module LunaCore
  • Initialize the main object with LCBestShotBuilder
  • Implement delegate methods LCBestShotDelegate
  • Send frames of the video stream using the pushFrame (:) method until the best shot is found. To capture a video stream, use the CameraCaptureManager service from the LunaCamera module, or implement the capture yourself via AVCaptureSession
import LunaCore
import LunaCamera

class ViewController: UIViewController, LCBestShotDelegate {

    private lazy var bestShowDetector: LCBestShotDetectorProtocol = {
        let configuration = LunaCore.LCLunaConfiguration.defaultConfig()
        let livenessAPI = LunaWeb.LivenessAPIv6(configuration: configuration)
        let detector = LunaCore.LCBestShotBuilder.build(with: self, livenessAPI: livenessAPI, configuration: configuration)
        return detector
    }()

    private lazy var captureManager = LunaCamera.CameraCaptureManager()

    override func viewDidLoad() {
        super.viewDidLoad()
        setup()
    }

    override func viewDidDisappear(_ animated: Bool) {
        super.viewDidDisappear(animated)
        captureManager.stop()
    }

    private func setup() {
        captureManager.configure(withCameraPosition: .front)
        captureManager.captureHandler = { [weak self] sampleBuffer in
            self?.bestShowDetector.pushFrame(sampleBuffer)
        }
    }

    func detectionRect(rect: CGRect, inFrameSize frameSize: CGSize) {
        // Called when a face is detected in the shot.
    }

    func bestShot(_ bestShot: LunaCore.BestShot) -> Bool {
        // Called when the best shot is found.
        // Return true, if the new best shots are no longer needed.
    }

    func bestShotError(error: CameraError) {
        // Called when an error occurred.
    }

}

Using the LCDescriptorExtractorProtocol

The LCDescriptorExtractorProtocol allows you to extract a descriptor from the best snapshot as well as compare descriptors. Requires CompleteEdition license.

let extractor = LCDescriptorExtractorBuilder.build()

let firstDescriptorData = extractor.extractDescriptorData(from: firstBestShot)
let lastDescriptorData = extractor.extractDescriptorData(from: lastBestShot)

let similarity = extractor.matchDescriptorsData(firstDescriptorData, and: lastDescriptorData)

Using LCFaceDetectorProtocol

LCFaceDetectorProtocol detects faces in the image.

let detector = LCFaceDetectorBuilder.build()

let detections: [LCFaceDetection] = detector.detectFaces(image, maxCount)