Installation instructions

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

LunaCamera allows you to capture a video stream, display it on the screen and get the best shot. Consists of two public services:

  • CameraUIController
  • CameraCaptureManager

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

LunaCamera Integration

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

License setup and activation


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    LCLunaConfiguration.setLunaAccountID("00000000-1111-2222-3333-444444444444")
    LCLunaConfiguration.setServerURL(URL(string: "Luna API URL")!, force: true)
    LCLunaConfiguration.activateLicense()

    return true
}

Using CameraUIController

  • Import modules LunaCamera,LunaWeb, LunaCore
  • Initialize the main object with LunaCameraBuilder
  • Implement the methods of the CameraUIDelegate delegate
  • Present the resulting controller present (cameraController, animated: true)
import LunaCamera
import LunaWeb
import LunaCore

class ViewController: UIViewController, CameraUIDelegate {

    private lazy var cameraController: CameraUIController = {
        let configuration = LunaCore.LCLunaConfiguration.defaultConfig()
        let livenessAPI = LunaWeb.LivenessAPIv6(configuration: configuration)
        let controller = LunaCameraBuilder.viewController(delegate: self, configuration: configuration, livenessAPI: livenessAPI)
        return controller
    }()

    @IBAction func showCamera(_ sender: UIButton) {
        present(cameraController, animated: true)
    }

    func bestShot(_ bestShot: LunaCore.LCBestShot) {
        // Called when the best shot of the face is found.
    }

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

}

Using CameraCaptureManager

  • Import the module LunaCamera
  • Initialize the main object CameraCaptureManager
  • Configure using the configure (withCameraPosition:) method
  • Implement the captureHandler property
class ViewController: UIViewController {

    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)
        }
    }

}