Skip to content
Ver-ID SDK for Android
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs Renamed result and settings types Apr 15, 2019
gradle/wrapper
sample
veridui Added preference support library and theme Apr 16, 2019
.gitignore Initial commit Feb 19, 2019
.gitmodules
MigratingFromLegacySDK.md Added instructions for migrating from legacy SDK Apr 15, 2019
README.md
build.gradle Updated to latest version Apr 16, 2019
gradle.properties Initial commit Feb 19, 2019
gradlew Initial commit Feb 19, 2019
gradlew.bat Initial commit Feb 19, 2019
settings.gradle

README.md

Maven metadata URL

Ver-ID UI for Android

This project along with Ver-ID Core replace the legacy Ver-ID SDK. The new API is not compatible with the legacy SDK. Please refer to the migration instructions.

Prerequisites

To build this project and to run the sample app you will need a computer with these applications:

Installation

  1. Open a shell console and enter the following commands:

    git clone --recurse-submodules https://github.com/AppliedRecognition/Ver-ID-UI-Android.git
  2. Open Android Studio and from the top menu select File/Open.... Navigate to the directory where you checked out the Git project and press Open.

  3. Connect your Android device for debugging via USB.

  4. In the main menu select Run/Run 'sample'. Select your Android device and press OK.

Adding Ver-ID to your own project

  1. Request API secret for your app. We will need your app's package name.

  2. Add the Applied Recognition repository to the repositories in your app module's gradle.build file:

    repositories {
        maven {
            url 'https://dev.ver-id.com/artifactory/gradle-release'
        }
    }
  3. Add the following dependency to your gradle.build file:

    dependencies {
        implementation 'com.appliedrec.verid:ui:1.0.0'
    }
  4. Add RenderScript in your gradle.build file:

    android {
        defaultConfig {
            renderscriptTargetApi 14
            renderscriptSupportModeEnabled true
        }
    }
  5. Your app's assets must include Ver-ID-Models. Clone the folder using Git instead of downloading the Zip archive. Your system must have Git LFS installed prior to cloning the folder. Add the contents as a folder named VerIDModels to your app's assets folder.

    git clone -b matrix-16 https://github.com/AppliedRecognition/Ver-ID-Models.git VerIDModels
  6. Add the API secret in your app's manifest XML:

    <manifest>
        <application>
            <meta-data
                android:name="com.appliedrec.verid.apiSecret"
                android:value="yourApiSecret" />
        </application>
    </manifest>

Usage

Creating Ver-ID Environment

Prior to running Ver-ID sessions you will need to create an instance of Ver-ID.

VerIDFactory verIDFactory = new VerIDFactory(getContext(), new VerIDFactoryDelegate() {
    @Override
    public void veridFactoryDidCreateEnvironment(VerIDFactory verIDFactory, VerID verID) {
        // You can now use the VerID instance
    }

    @Override
    public void veridFactoryDidFailWithException(VerIDFactory verIDFactory, Exception e) {
        // Failed to create an instance of Ver-ID
    }
});
verIDFactory.createVerID();

Running Ver-ID Session Activities

class MyActivity extends AppCompatActivity {

    static final int REQUEST_CODE_LIVENESS_DETECTION = 0;

    void startLivenessDetectionSession() {
        VerIDFactory veridFactory = new VerIDFactory(this, new VerIDFactoryDelegate() {
            @Override
            public void veridFactoryDidCreateEnvironment(VerIDFactory verIDFactory, VerID verID) {
                // You can now start a Ver-ID session
                LivenessDetectionSessionSettings settings = new LivenessDetectionSessionSettings();
                settings.setNumberOfResultsToCollect(2);
                Intent intent = new VerIDSessionIntent(this, verID, settings);
                startActivityForResult(intent, REQUEST_CODE_LIVENESS_DETECTION);
            }

            @Override
            public void veridFactoryDidFailWithException(VerIDFactory verIDFactory, Exception e) {
                // Failed to create an instance of Ver-ID
            }
        });
        veridFactory.createVerID();
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == REQUEST_CODE_LIVENESS_DETECTION && resultCode == RESULT_OK && data != null) {
            VerIDSessionResult sessionResult = data.getParcelableExtra(VerIDSessionActivity.EXTRA_RESULT);
            if (sessionResult != null && sessionResult.getError() == null) {
                // Liveness detection session succeeded
            }
        }
    }
}

Customizing Ver-ID Session Behaviour

The Ver-ID session activity finishes as the session concludes. If you want to change this or other behaviour of the session you can write your own activity class that extends VerIDSessionActivity.

For an example of an activity that extends VerIDSessionActivity take a look at AuthenticationActivity in the Ver-ID Kiosk sample app.

Controlling Liveness Detection

If you run a Ver-ID session with LivenessDetectionSessionSettings or its subclass AuthenticationSessionSettings you can control how Ver-ID detects liveness.

To disable liveness detection set the session's number of results to collect to 1.

To control the bearings the user may be asked to assume call the setBearings(EnumSet) method. For example, to ask the user to look straight at the camera and then assume 2 random poses from the choice of left and right modify the settings as follows:

LivenessDetectionSessionSettings settings = new LivenessDetectionSessionSettings();
settings.setNumberOfResultsToCollect(3); // 1 straight plus 2 other poses
settings.setBearings(EnumSet.of(Bearing.STRAIGHT, Bearing.LEFT, Bearing.RIGHT)); // Limit the poses to left and right

The session result will contain 3 faces: 1 looking straight at the camera and 2 in random poses.

Replacing Components in the Ver-ID Environment

You can have Ver-ID your own user management (face template storage) layer or even your own face detection and face recognition. To do that create an appropriate factory class and set it on the Ver-ID factory before calling the createVerID() method.

For example, to add your own storage layer:

VerIDFactory verIDFactory = new VerIDFactory(this, this);
IUserManagementFactory userManagementFactory = new IUserManagementFactory() {
    @Override
    public IUserManagement createUserManagement() throws Exception {
        return new IUserManagement() {
            @Override
            public void assignFacesToUser(IRecognizable[] faces, String userId) throws Exception {
                
            }

            @Override
            public void deleteFaces(IRecognizable[] faces) throws Exception {

            }

            @Override
            public String[] getUsers() throws Exception {
                return new String[0];
            }

            @Override
            public IRecognizable[] getFacesOfUser(String userId) throws Exception {
                return new IRecognizable[0];
            }

            @Override
            public IRecognizable[] getFaces() throws Exception {
                return new IRecognizable[0];
            }

            @Override
            public void deleteUsers(String[] userIds) throws Exception {

            }

            @Override
            public void close() {

            }
        };
    }
};
verIDFactory.setUserManagementFactory(userManagementFactory);
verIDFactory.createVerID();

Full documentation available on the project's Github page.

You can’t perform that action at this time.