Skip to content

Liveness detection

There are two selfie alive modes, Selfie Alive and Selfie Alive Pro. The goal of both is to verify the user identity and detect if you are alive with an active challenge.

The selfie alive pro will not work without a token provided by the Veridas endpoint /challenges/generation. If the token is not passed to the configuration it will only enable selfie alive.

Selfie Alive

If the live photo is activated, and the device is capable of it, there will be two possible images to send to server from two delegated methods.

To activate the Selfie Alive process it is necessary to configure "livephoto" key to "YES".

The image received into the VDPhotoSelfieCapturedWithLiveDetection: andFace: method is appropriate for biometric verification. The image received into the VDPhotoSelfieCaptured: andFace: method is appropriate for authenticity verification.

Recognition Selfie Alive
Image1 Image2

Selfie Alive Pro

Selfie Alive Pro process consist in doing a challenge with several movements in different directions. It is stronger than Selfie Alive process because of the challenge.

To activate the Selfie Alive Pro process it is necessary configure "livephoto" key to "YES" and "jws_token" with a challenge token. This token must be retrieved from the backend (the call /challenges/generation gets a string with the "jws_token" configuration) and introduced to the SDK before it is started.

The delegated methods of Selfie Alive Pro are:

- VDPhotoChallengeVideoCaptured: andFile: This method delegates the challenge video in mp4 format, resolution of 1280x720 with an approximate size of 0.7MB for a 10 seconds video. The file is in WebVtt format and describes the completed process and has to be sent to the backend too.

- VDPhotoSelfieCaptured: andFace: As Photo Selfie process.

- VDPhotoSelfieChallengeFinishedWithError This method is delegated when the process fails. In this case it is possible to update the required challenge with the public method VDPhotoSelfieCapture.setChallenge("other challenge");, otherwise the users second attempt will be done with the same challenge.

Recognition Selfie Alive Pro

Example of use

Objective-C

#import "VDPhotoSelfieCapture/VDPhotoSelfieCapture.h" // Objective-C
@‌interface ViewController () <VDPhotoSelfieCaptureProtocol> { // Objective-C
    // Call something like this to start the photo selfie capture
    // LIVE SELFIE
    NSDictionary* configuration = @ {"closebutton": "NO", "livephoto": "YES"}
    if !VDPhotoSelfieCapture.isStarted() {
            [VDPhotoSelfieCapture startWithDelegate:self andConfiguration: configuration];
    }

    // Call something like this to start the photo selfie pro capture
    // LIVE SELFIE PRO. YOUR_TOKEN is retrieved from our server.
    NSDictionary* configuration = @ {"closebutton": "NO", "livephoto": "YES", "jws_token": YOUR_TOKEN}
    if !VDPhotoSelfieCapture.isStarted() {
            [VDPhotoSelfieCapture startWithDelegate:self andConfiguration: configuration];
    }

    ....

    // Delegated methods.
    // Called when the selfie has been captured
    - (void)VDPhotoSelfieCaptured:(NSData *)photoSelfieData andFace:(NSData *)face {
        // Do with images as needed.
    }

    - (void)VDPhotoSelfieCapturedWithLiveDetection:(NSData *)photoSelfieData andFace:(NSData *)face {
        // In case the configuration for "livephoto" is "YES", this is a picture of the person with a more natural pose but with lower quality.
    }

    // (Selfie Alive Pro) In case the configuration for "livephoto" is "YES" and the "jws_token" is configured correctly.
    - (void) VDPhotoChallengeVideoCaptured:(NSData *)videoChallenges andFile:(NSData *) file {

    }

    // (Selfie Alive Pro) In case of Selfie Alive Pro error and the configuration for "livephoto" is "YES" and the "jws_token" is configured correctly.
    - (void) VDPhotoSelfieChallengeFinishedWithError {

    }

    // Called when the framework has finished.
    // processFinished (Boolean) Indicates if the process has finished (true) or has been interrupted (false)
    - (void)VDPhotoSelfieAllFinished: (Boolean)processFinished {
        // SELFIE ALIVE PRO
        // Send the data to: /challenges/video-photo with the following parameters in the body:
        // token: the token provided by the server,
        // video: the video data retrieved in vdPhotoChallengeVideoCaptured,
        // annotations: the file data retrieved in vdPhotoChallengeVideoCaptured,
        // selfie: the face data retrieved in vdPhotoSelfieCaptured.
    }
}

Swift

import VDPhotoSelfieCapture
class MyClass: VDPhotoSelfieCaptureProtocol {
    // PROTOCOL IMPLEMENTATION.
    // Called when a selfie image has been captured
    func vdPhotoSelfieCaptured(_ photoSelfieData: Data!, andFace face: Data!) {
        // Do with images as needed.
    }
    // (Selfie Alive) In case the configuration for "livephoto" is "YES", this is a picture of the person with a more natural pose but with lower quality.
    func vdPhotoSelfieCaptured(withLiveDetection photoSelfieData: Data!, andFace face: Data!) {
        // Do with images as needed.
    }

    // (Selfie Alive Pro) In case the configuration for "livephoto" is "YES" and the "jws_token" is configured correctly.
    func vdPhotoChallengeVideoCaptured(_ videoChallenges: Data!, andFile file: Data!) {
            print("Photo vdPhotoChallengeVideoCaptured")
    }

    // (Selfie Alive Pro) In case of Selfie Alive Pro error.
    func vdPhotoSelfieChallengeFinishedWithError() {
        // Proceed as needed, example ask for a new challenge and update it in the sdk with VDPhotoSelfieCapture.setChallenge("other challenge")
    }

    // Called when the framework has finished.
    // processFinished (Boolean) Indicates if the process has finished (true) or has been interrupted (false)
    func vdPhotoSelfieAllFinished(_ processFinished: Bool) {
        // SELFIE ALIVE PRO
        // Send the data to: /challenges/video-photo with the following parameters in the body:
        // token: the token provided by the server,
        // video: the video data retrieved in vdPhotoChallengeVideoCaptured,
        // annotations: the file data retrieved in vdPhotoChallengeVideoCaptured,
        // selfie: the face data retrieved in vdPhotoSelfieCaptured.
    }

    ....

    // Call something like this to start the photo selfie capture
    // LIVE SELFIE
    let configuration: [String : Any] = ["closebutton": "NO", "livephoto": "YES"]
    if !VDPhotoSelfieCapture.isStarted() {
        VDPhotoSelfieCapture.start(withDelegate: self, andConfiguration: configuration)
    }

    // Call something like this to start the photo selfie pro capture
    // LIVE SELFIE PRO. YOUR_TOKEN is retrieved from our server.
    let configuration: [String : Any] = ["closebutton": "NO", "livephoto": "YES", "jws_token": YOUR_TOKEN]
    if !VDPhotoSelfieCapture.isStarted() {
        VDPhotoSelfieCapture.start(withDelegate: self, andConfiguration: configuration)
    }
}

Workflow

The next diagram represents de current Alive workflow of the framework. Some method's names may de shortened due to legibility issues.

Workflow

Alive Pro Workflow

The next diagram represents de current Alive Pro workflow of the framework. Some method's names may de shortened due to legibility issues.

Workflow