Skip to content

Recording a video stream only with the face detected#

With LUNA ID, you can record either entire video sessions or only video sessions in which a face was detected in at least one frame.

In LUNA ID for Android#

To record a video stream only with the face detected, call LunaID.showCamera() with ShowCameraParams(recordVideo=true, ignoreVideoWithoutFace=true).

You can optionally set up a fixed delay or specific moment in time to define when the face recognition will start after the camera is displayed in the screen. To do this, use the StartBestShotSearchCommand command.

In LUNA ID for iOS#

To record a video stream only with the face detected, pass appropriate values for the recordVideo and configuration parameters to the LMCameraBuilder.viewController camera controller instance creation function:

let controller = LMCameraBuilder.viewController(delegate: self,
                                                    configuration: LCLunaConfiguration,
                                                    recordVideo: true)
Parameter Description
configuration The parameter is represented by the LCLunaConfiguration structure. The LCLunaConfiguration → saveOnlyFaceVideo = true parameter is responsible for saving video files only with a face detected.
recordVideo The parameter is responsible for saving the video file.

You can find the video file path in the bestShot function in the LMCameraDelegate protocol.

public protocol LMCameraDelegate: AnyObject {

    func bestShot(_ bestShot: LunaCore.LCBestShot, _ videoFile: String?)

    func error(_ error: LMCameraError, _ videoFile: String?)

}

You can also set up a delay, in seconds, to define when the face recognition will start after the camera is displayed in the screen. To do this, use LCLunaConfiguration.startDelay.

The detected face in the frame is tracked all the time when the camera is on.