Active Passive Liveness Detection

Configuration

To use any Sybrin SDK you will need a Sybrin issued license. You can have a look at our licensing page to request a license.

Using the license provided you will need to build and instance of the SybrinLivenessDetectionConfiguration class that will help with configuring the SDKs' behavior.

For example:

SybrinLivenessDetectionConfiguration sldc = new SybrinLivenessDetectionConfiguration
        .Builder(<sybrin_license_here>)
        .build();

To see the full range of configuration available please visit the SybrinLivenessDetectionConfiguration page

Calling feature

To start the active liveness detection process you will need to get an instance of the SybrinLivenessDetection class using the configuration built earlier. With this object you will be able to call the openActivePassiveLivenessDetection method, which can optionally be provided an array of ActivePassiveLivenessDetectionAction as a parameter. Finally you can register for the 3 different callbacks right on the method call.

For example:

SybrinLivenessDetection sld = SybrinLivenessDetection.getInstance(this, sldc);
 
si.openActivePassiveLivenessDetection()
        .addOnSuccessListener(new ActivePassiveLivenessDetector.OnSuccessListener<ActivePassiveLivenessDetectionModel>() {
            @Override
            public void onSuccess(ActivePassiveLivenessDetectionModel result) {
                // Handle success
            }
        })
        .addOnFailureListener(new ActivePassiveLivenessDetector.OnFailureListener() {
            @Override
             public void onFailure(LivenessDetectionException lde) {
                // Handle failure
            }
        })
        .addOnCancelListener(new ActivePassiveLivenessDetector.OnCancelListener() {
            @Override
            public void onCancel() {
                // Handle cancelation
            }
        });

For example with explicit actions:

SybrinLivenessDetection sld = SybrinLivenessDetection.getInstance(this, sldc);

ActivePassiveLivenessDetectionAction[] aplda = {
          ActivePassiveLivenessDetectionAction.Blink,
          ActivePassiveLivenessDetectionAction.Smile      
        };
   
si.openActivePassiveLivenessDetection(aplda)
        .addOnSuccessListener(new ActivePassiveLivenessDetector.OnSuccessListener<ActivePassiveLivenessDetectionModel>() {
            @Override
            public void onSuccess(ActivePassiveLivenessDetectionModel result) {
                // Handle success
            }
        })
        .addOnFailureListener(new ActivePassiveLivenessDetector.OnFailureListener() {
            @Override
             public void onFailure(LivenessDetectionException lde) {
                // Handle failure
            }
        })
        .addOnCancelListener(new ActivePassiveLivenessDetector.onCancelListener() {
            @Override
            public void onCancel() {
                // Handle cancelation
            }
        });

Subscribing to any of the callbacks on the openActivePassiveLivenessDetection method is optional.

Handling callback responses

There are 3 different callbacks that can be subscribed to. They are as follows:

OnSuccessListener

When the SDK has completed the liveness detection process the result will be posted to the OnSuccessListener.onSuccess callback. The ActivePassiveLivenessDetectionModel is returned as a result.

For example:

si.openActivePassiveLivenessDetection()
        .addOnSuccessListener(new ActivePassiveLivenessDetector.OnSuccessListener<ActivePassiveLivenessDetectionModel>() {
            @Override
            public void onSuccess(ActivePassiveLivenessDetectionModel result) {
                
                // Handle success
                boolean isAlive = result.isAlive();
            }
        });

OnFailureListener

When the SDK encounters an error a LivenessDetectionException is posted to the OnFailureListener.onFailure callback. The LivenessDetectionException will contain all the needed information to help solve the issue causing the error.

For example:

si.openActivePassiveLivenessDetection()
        .addOnFailureListener(new ActivePassiveLivenessDetector.OnFailureListener() {
            @Override
             public void onFailure(LivenessDetectionException lde) {
            
                // Get error message
                String error = lde.getLocalizedMessage();
            }
        });

If you would like to report a bug, contact us!

OnCancelListener

When the scanning process is interrupted by the user by pressing the back button the SDK will post a response to the OnCancelListener.onCancel callback. This callback has no return value.

For example:

si.openActivePassiveLivenessDetection()
        .addOnCancelListener(new ActivePassiveLivenessDetector.OnCancelListener() {
            @Override
            public void onCancel() {
                // Do something when scanning is cancelled
            }
        });

Full example

Activity.java
SybrinLivenessDetectionConfiguration sldc = new SybrinLivenessDetectionConfiguration
        .Builder(<sybrin_license_here>)
        .build();
        
SybrinLivenessDetection sld = SybrinLivenessDetection.getInstance(this, sldc);
   
si.openActivePassiveLivenessDetection()
        .addOnSuccessListener(new ActivePassiveLivenessDetector.OnSuccessListener<ActivePassiveLivenessDetectionModel>() {
            @Override
            public void onSuccess(ActivePassiveLivenessDetectionModel result) {
                
                // Handle success
                boolean isAlive = result.isAlive();
            }
        })
        .addOnFailureListener(new ActivePassiveLivenessDetector.OnFailureListener() {
            @Override
             public void onFailure(LivenessDetectionException lde) {
            
                // Get error message
                String error = lde.getLocalizedMessage();
            }
        })
        .addOnCancelListener(new ActivePassiveLivenessDetector.OnCancelListener() {
            @Override
            public void onCancel() {
                // Do something when scanning is cancelled
            }
        });

Last updated