Biometrics Android
1.3
Search
K

Facial Recognition

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 SybrinFacialRecognitionConfiguration class that will help with configuring the SDKs' behavior.

For example:

SybrinFacialRecognitionConfiguration sfrc = new SybrinFacialRecognitionConfiguration
.Builder(<sybrin_license_here>)
.build(context);
To see the full range of configuration available please visit the SybrinFacialRecognitionConfiguration page

Calling feature

Did you know that you are able to pre-load all components needed for training and authentication? By using the loadModel method found on the SybrinFacialRecognition class you are able to download previously trained models and initialize the machine learning components for a smoother start up!
To start the facial recognition authentication process you will need to get an instance of the SybrinFacialRecognition class using the configuration built earlier. With this object you will be able to call the openFacialRecognition method, which takes an identifying string as a parameter. The identifier should match the identifier provided to the facial recognition training.
Once recognition authentication succeeds the model is retrained and re-uploaded to Sybrin's online data stores.
Finally you can register for the 3 different callbacks right on the method call.

For example:

String identifier = "uniqueIdentifier";
SybrinFacialRecognition sfr = SybrinFacialRecognition.getInstance(this, sfrc);
sfr.openFacialRecognition(identifier)
.addOnSuccessListener(new FacialRecognizer.OnSuccessListener<FacialRecognitionModel>() {
@Override
public void onSuccess(FacialRecognitionModel result) {
// Handle success
}
})
.addOnFailureListener(new FacialRecognizer.OnFailureListener() {
@Override
public void onFailure(FacialRecognitionException fre) {
// Handle failure
}
})
.addOnCancelListener(new FacialRecognizer.onCancelListener() {
@Override
public void onCancel() {
// Handle cancelation
}
});
Sybrin does not provide user management for the identifiers that are used to train and recognize on a specific license key. The proper management and storage of unique identifiers is the sole responsibility of the developer.
Subscribing to any of the callbacks on the trainFaces 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 facial recognition authentication process the result will be posted to the OnSuccessListener.onSuccess callback. The FacialRecognitionModel is returned as a result.

For example:

sfr.openFacialRecognition(identifier)
.addOnSuccessListener(new FacialRecognizer.OnSuccessListener<FacialRecognitionModel>() {
@Override
public void onSuccess(FacialRecognitionModel result) {
// Handle success
float confidence = result.getConfidence();
}
});

OnFailureListener

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

For example:

sfr.trainFaces(identifier)
.addOnFailureListener(new FacialRecognizer.OnFailureListener() {
@Override
public void onFailure(FacialRecognitionException fre) {
// Get error message
String error = fre.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:

sfr.trainFaces(identifier)
.addOnCancelListener(new FacialRecognizer.OnCancelListener() {
@Override
public void onCancel() {
// Do something when scanning is cancelled
}
});

Full example

Activity.java
SybrinFacialRecognitionConfiguration sfrc = new SybrinFacialRecognitionConfiguration
.Builder(<sybrin_license_here>)
.build(context);
String identifier = "uniqueIdentifier";
SybrinFacialRecognition sfr = SybrinFacialRecognition.getInstance(this, sfrc);
sfr.openFacialRecognition(identifier)
.addOnSuccessListener(new FacialRecognizer.OnSuccessListener<FacialRecognitionModel>() {
@Override
public void onSuccess(FacialRecognitionModel result) {
// Handle success
float confidence = result.getConfidence();
}
})
.addOnFailureListener(new FacialRecognizer.OnFailureListener() {
@Override
public void onFailure(FacialRecognitionException fre) {
// Get error message
String error = fre.getLocalizedMessage();
}
})
.addOnCancelListener(new FacialRecognizer.OnCancelListener() {
@Override
public void onCancel() {
// Do something when scanning is cancelled
}
});