Load Model

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

To start the facial recognition initialization 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 loadModelmethod, which takes an identifying string as a parameter. The identifier is used to to locate the stored recognition model on Sybrin's storage servers.

The loadModel feature initializes all machine learning components needed to perform facial recognition and training as well as downloads the stored recognition model associated with the provided identifier. A model is only downloaded if it is available.

The Facial Recognition and Facial Training features will run this method if it has not been called before.

Finally you can register for the different callbacks right on the method call.

For example:

String identifier = "uniqueIdentifier";

SybrinFacialRecognition sfr = SybrinFacialRecognition.getInstance(this, sfrc);
 
sfr.loadModel(identifier)
        .addOnSuccessListener(new FacialRecognitionInitializer.OnSuccessListener<FacialRecognitionInitializationModel>() {
            @Override
            public void onSuccess(FacialRecognitionInitializationModel result) {
                // Handle success
            }
        })
        .addOnFailureListener(new FacialRecognitionInitializer.OnFailureListener() {
            @Override
             public void onFailure(FacialRecognitionException fre) {
                // Handle failure
            }
        });

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 loadmodelmethod is optional.

Handling callback responses

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

OnSuccessListener

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

For example:

sfr.loadModel(identifier)
        .addOnSuccessListener(new FacialRecognitionInitializer.OnSuccessListener<FacialRecognitionInitializationModel>() {
            @Override
            public void onSuccess(FacialRecognitionInitializationModel result) {
                
                // Handle success
                boolean isModelDownloaded = result.isModelDownloaded();
            }
        });

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.loadModel(identifier)
        .addOnFailureListener(new FacialRecognitionInitializer.OnFailureListener() {
            @Override
             public void onFailure(FacialRecognitionException fre) {
                
                // Handle failure
                String error = fre.getLocalizedMessage();
            }
        });

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

Full example

Activity.java
SybrinFacialRecognitionConfiguration sfrc = new SybrinFacialRecognitionConfiguration
        .Builder(<sybrin_license_here>)
        .build(context);
        
String identifier = "uniqueIdentifier";

SybrinFacialRecognition sfr = SybrinFacialRecognition.getInstance(this, sfrc);
 
sfr.loadModel(identifier)
        .addOnSuccessListener(new FacialRecognitionInitializer.OnSuccessListener<FacialRecognitionInitializationModel>() {
            @Override
            public void onSuccess(FacialRecognitionInitializationModel result) {
                
                // Handle success
                boolean isModelDownloaded = result.isModelDownloaded();
            }
        })
        .addOnFailureListener(new FacialRecognitionInitializer.OnFailureListener() {
            @Override
             public void onFailure(FacialRecognitionException fre) {
                
                // Handle failure
                String error = fre.getLocalizedMessage();
            }
        });

Last updated