Skip to content
Switch branches/tags

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Ver-ID Credentials Sample

The project contains a sample application that uses Microblink's BlinkID SDK to scan an ID card. The app uses Ver-ID SDK to detect a face on the captured ID card and compare it to a live selfie taken with the Android device's camera.

Before you build the app

  1. The sample app uses view binding. Ensure you're building the project with Android Studio 3.6 or newer.
  2. Create a new project in Google Firebase console and add an Android app with package name
  3. Download the google-services.json file generated by Firebase and add it to the project's app folder.

Adding Ver-ID to your Android Studio project

  1. Register your app. You will need your app's package name.

  2. Registering your app will generate an evaluation licence for your app. The licence is valid for 30 days. If you need a production licence please contact Applied Recognition.

  3. When you finish the registration you'll receive a file called Ver-ID identity.p12 and a password. Copy the password to a secure location.

  4. Copy the Ver-ID identity.p12 into your app's assets folder. A common location is your_app_module/src/main/assets.

  5. Ver-ID will need the password you received at registration.

    • You can either specify the password when you create an instance of VerIDFactory:

      VerIDFactory veridFactory = new VerIDFactory(this, "your password goes here");
    • Or you can add the password in your app's AndroidManifest.xml:

                  android:value="your password goes here" />
  6. Add the Applied Recognition repository and Ver-ID dependencies to your app module's file:

    repositories {
        maven { url '' }
    dependencies {
        implementation 'com.appliedrec.verid:ui2:[2.0,3.0['

Adding Microblink to your Android Studio project

  1. Apply for an API key on the Microblink website.

  2. Open your app module's file and add:

    repositories {
        maven { url '' }
    dependencies {
        implementation('com.microblink:blinkid:5.11.0@aar') {
            transitive = true
  3. Detailed instructions are available on the BlinkID Github page.

Example 1 – Capture ID card

public class MyActivity extends AppCompatActivity {
    private RecognizerBundle recognizerBundle;
    private VerID verID; // See Example 2 for instructions on how to load VerID
    private static final int REQUEST_CODE_ID_CAPTURE = 0;
     * Call this method to start the ID capture 
     * (for example in response to a button click).
    void startCapture() {
        try {
            // Set the Microblink licence key
            // This example assumes the key is set in your build.gradle file
            MicroblinkSDK.setLicenseKey(BuildConfig.BLINK_LICENCE_KEY, this);
        } catch (InvalidLicenceKeyException e) {
            // You'll want to handle this better
        // To enable high-res images in intents
        // Create a recognizer to detect an ID card
        BlinkIdCombinedRecognizer recognizer = new BlinkIdCombinedRecognizer();
        recognizerBundle = new RecognizerBundle(recognizer);
        BlinkIdUISettings uiSettings = new BlinkIdUISettings(recognizerBundle);
        startActivityForResult(intent, REQUEST_CODE_ID_CAPTURE);
     * Listen for the result of the ID capture and display 
     * the card and detected face in your activity.
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == REQUEST_CODE_ID_CAPTURE && resultCode == RESULT_OK && data != null) {
            try {
                // Load the ID capture result from the data intent
                Recognizer<?> firstRecognizer = recognizerBundle.getRecognizers()[0];
                if (firstRecognizer instanceof BlinkIdCombinedRecognizer) {
                    BlinkIdCombinedRecognizer.Result result = ((BlinkIdCombinedRecognizer)firstRecognizer).getResult();
                    if (result.getDocumentDataMatch() == DataMatchResult.Failed) {
                        // The back and front of the card don't match
                        throw new Exception("Front and back of the ID card don't match");
                byte[] frontImage = result.getEncodedFrontFullDocumentImage();
                if (frontImage.length == 0) {
                    throw new Exception("Unable to retrieve an image of the ID card");
                Bitmap frontImageBitmap = BitmapFactory.decodeByteArray(frontImage, 0, frontImage.length);
                VerIDImageBitmap image = new VerIDImageBitmap(frontImageBitmap, ExifInterface.ORIENTATION_NORMAL);
                Face[] faces = verID.getFaceDetection().detectFacesInImage(image.createFaceDetectionImage(), 1, 0);
                if (faces.length > 0) {
                    RecognizableFace[] recognizableFaces = verID.getFaceRecognition().createRecognizableFacesFromFaces(faces, image);             
                    RecognizableFace face = recognizableFaces[0];
                    // Face can be used for face recognition
                } else {
                    throw new Exception("Failed to detect a face on the ID card");
            } catch (Exception e) {
                // TODO: Handle exception

Example 2 – Capture live face

public class MyActivity extends AppCompatActivity implements VerIDFactoryDelegate, VerIDSessionDelegate {
    protected void onCreate(Bundle savedInstanceState) {
     * Call this method to start the liveness detection session
     * (for example in response to a button click).
    void startLivenessDetection() {
        // Load Ver-ID
        VerIDFactory verIDFactory = new VerIDFactory(this, this);
    //region VerIDFactoryDelegate
    public void onVerIDCreated(VerIDFactory factory, VerID verID) {
        // Create liveness detection settings
        LivenessDetectionSessionSettings settings = new LivenessDetectionSessionSettings();
        // Create VerIDSession
        VerIDSession session = new VerIDSession(verId, settings);
    public void onVerIDCreationFailed(VerIDFactory factory, Exception error) {
    //region VerIDSessionDelegate
    public void onSessionFinished(IVerIDSession<?> session, VerIDSessionResult result) {
        // Check if result contains an error
        if (result.getError().isPresent()) {
            // Liveness detection failed
        // Grab the first face capture where the user is looking straight at the camera
        result.getFirstFaceCapture(Bearing.STRAIGHT).ifPresent(capture => {
            // Face from capture.getFace() can be used for face recognition

Example 3 - Compare face on ID card with live face

Building on example 1 and 2, you can use the results of the ID capture and liveness detection sessions and compare their faces.

class FaceComparison {

    // Refer to Example 1 to see how to detect a face in an ID card
    // Refer to Example 2 to see how to load VerID and detect a "live" face
    static float compareFaces(VerID verID, RecognizableFace face1, RecognizableFace face2) throws Exception {
        return verID.getFaceRecognition().compareSubjectFacesToFaces(new IRecognizable[]{face1}, new IRecognizable[]{face2});





Android app that demonstrates ID capture and face comparison using Ver-ID



No packages published