A sample project of implementing Liveness Detection and Identity OCR on Android app using Kredibel Vision SDK

Overview

Vision Sample (Android)

gradle targetsdk ktx

A sample project of implementing Liveness Detection and Identity OCR on Android app using Kredibel Vision SDK.

You can checkout the source code of this project.

git clone https://github.com/kredibel-id/VisionSample-Android.git

Then open this sample project with Android Studio or Intellij IDEA.







Vision SDK

Introduction

Vision SDK is a library that provides computer vision services such as Liveness Detection and Identity OCR with Kredibel VisionAI technology.

Features

Liveness Detection
  1. Examine the digital representation of the user's face from the camera preview in realtime.
  2. Out-of-frame face detection to prevent spoofing.
  3. Analyze multiple movements, including head movements, eye blinks, smiles and mouth opening to determine activity.
  4. Determine whether it is a living person or not.
Identity OCR

Identity OCR is an Optical Character Recognition (OCR) service that supports some types :

  1. National Identity (KTP)
  2. Driving License (SIM)
  3. Passport
  4. Handheld with Id Card selfie

Currently the Vision SDK can only be used on the Android platform.

Support API Level

minsdk targetsdk

Install / Setup

  • Aar file size : 2,7 MB

Gradle

1. Add kredibel repository.

maven{url 'https://repo.repsy.io/mvn/kredibel/sdk'}

You can do this in two alternative ways.

  • Latest way(Gradle 7+) : Add repository in dependencyResolutionManagement in setting.gradle.
dependencyResolutionManagement {
    repositories {
        ...
        ...
        maven{url 'https://repo.repsy.io/mvn/kredibel/sdk'} // <โ€”-- add this
    }
}
  • Old way : Add repository in build.gradle file at Project level.
allprojects {
    repositories {
       ...
       ...
       maven{url 'https://repo.repsy.io/mvn/kredibel/sdk'} // <โ€”-- add this 
    }
}

2. Add this dependency to gradle script on app module.

dependencies {
    implementation 'io.kredibel:vision:0.0.1-beta-20220313085304' // Please check latest version
}

API-Key

Please read the instructions here to get the API-Key or contact our sales team.

Config AndroidManifest.xml

After getting API-Key then open your AndroidManifest.xml than add a this meta-data in the scope of tag.

">
<meta-data android:name="io.kredibel.sdk.APIKEY" android:value="Your API-Key" /> 

Please name the attribute name with io.kredibel.sdk.APIKEY.

Example :

">
xml version="1.0" encoding="utf-8"?>
<manifest 
    xmlns:android="http://schemas.android.com/apk/res/android"
    package="id.web.hangga.visionsample">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.VisionSample">
        <activity
            android:name=".MainActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            intent-filter>
        activity>

        <meta-data
            android:name="io.kredibel.sdk.APIKEY"
            android:value="eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6OCw bla.. Bla.. bla.."/>
    application>
manifest>

How to Use (Basic Implementation)

The Vision class is the main class in the Kredibel Vision SDK. This class contains methods or functions to handle Liveness Detection and OCR quickly. You don't need to create a layout/UI, because we have provided everything. You just use all the functions/methods in the Vision class.

Liveness Detection

1. Single Detection

kotlin

Vision.with(this) // Context, required
    .detection(Detection.SMILE) // required
    .start()

java

Vision.with(this)
    .detection(Detection.SMILE) // required
    .start();

2. Multiple Detection

kotlin

Vision.with(this)
    .detection(arrayOf(Detection.SMILE, Detection.MOUTH_OPEN, Detection.BLINK_LEFT)) // required
    .delay(2000)  // milliseconds, optional. Default = 1000
    .start()

java

Vision.with(this)
    .detection(new String[]{Detection.SMILE, Detection.MOUTH_OPEN, Detection.BLINK_LEFT}) // required
    .delay(2000)  // milliseconds, optional. Default = 1000
    .start();

The following are some of the head and facial movements supported by the Vision SDK.

Face and Head Movements Parameters
Smile Detection.SMILE
Open mouth Detection.MOUTH_OPEN
Look Up Detection.LOOK_UP
Look to the right Detection.RIGHT
Looking down Detection.LOOKING_DOWN
Look to the left Detection.LEFT
Get random head and face movements Detection.RANDOM_HEAD_ANGLE
Left eye wink Detection.BLINK_LEFT
Right eye wink Detection.BLINK_RIGHT
Getting random winks Detection.RANDOM_EYE_BLINK

Identity OCR

kotlin

Vision.with(this)
    .identity(Identity.KTP)  // required. Identity type.
    .showOCRLastResult(true) // optional
    .onSuccessPage(SuccessPageActivity::class.java)  // optional
    .start()

java

Vision.with(this)
    .identity(Identity.KTP)  // required. Identity type.
    .showOCRLastResult(true) // optional
    .onSuccessPage(SuccessPageActivity.class)  // optional
    .start();

The following are some of the supported document types and their parameter names.

Dosument Type Parameters
Indonesian National Identity Card/ Kartu Tanda Penduduk(KTP) Identity.KTP
Driver's license Identity.SIM
Passport Identity.PASSPORT
Handheld with id card selfie Identity.HANDHELD

Get Result Data

You can use the onSuccessPage() method to select your activity that will receive the result data.

kotlin

Vision.with(this) // Context, required
    .detection(Detection.SMILE) // required
    .onSuccessPage(SuccessPageActivity::class.java) // optional for passing result data
    .start()

java

Vision.with(this)
    .detection(Detection.SMILE) // required
    .onSuccessPage(SuccessPageActivity.class) // optional for passing result data
    .start();

Then you can get result data from intent in your SuccessPageActivity on activity created override method with this parameters.

getParcelableArrayListExtra(Vision.RESULT_LIVENESS)

getParcelableExtra(Vision.RESULT_OCR)

Example :

kotlin

class SuccessPageActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_success_page)
        // get result data
        val livenessResults : List<LivenessResult> = intent.getParcelableArrayListExtra(Vision.RESULT_LIVENESS)!!
        val ocrResult : OcrResult = intent.getParcelableExtra(Vision.RESULT_OCR)!!
    }
}

java

public class SuccessPageActivity extends AppCompatActivity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_third);
        // get result data
        List<LivenessResult> livenessResults = getIntent().getParcelableArrayListExtra(Vision.RESULT_LIVENESS);
        OcrResult ocrResult = intent.getParcelableExtra(Vision.RESULT_OCR);
    }
}

Using VisionListener

You can use VisionListener for capture all detection results and or add a custom action after process.

If you use a VisionListener, then you don't need to call the onSuccessPage() method, because it won't run.

kotlin

Vision.with(this)
    .detection(arrayOf(Detection.SMILE, Detection.MOUTH_OPEN)) // required
    .listener(object : VisionListener{   // listener, optional on Liveness & OCR
        override fun onSuccess(livenessResult: MutableList<LivenessResult>?, ocrResult: OcrResult?) {
            // if you want to capture all detection results and or add a custom action.
        }

        override fun onError(s: String?) {
            showMessage(s!!)
        }
    })          
    .delay(2000)  // milliseconds, optional. Default = 1000
    .start()

java

Vision.with(this)
    .detection(new String[]{Detection.SMILE, Detection.MOUTH_OPEN}) // required
    .listener(new VisionListener() { // listener, optional on Liveness & OCR
        @Override
        public void onSuccess(List<LivenessResult> list, OcrResult ocrResult) {
            // if you want to capture all detection results and or add a custom action.
        }

        @Override
        public void onError(String s) {

        }
     })        
    .delay(2000)  // milliseconds, optional. Default = 1000
    .start();

Optional Features

Some optional features that you can use.

kotlin

Vision.with(this)
    .detection(arrayOf(Detection.SMILE, Detection.MOUTH_OPEN)) // required
    .delay(2000)  // milliseconds, optional. Default = 1000
    .onSuccessPage(SecondActivity::class.java) // optional
    .finishOnSuccess(true) // optional, for auto destroy current activity/context after liveness/ocr process.
    .showContour(true)     // optional
    .showLabel(true)       // optional
    .showBoundingBox(true) // optional
    .start()

java

Vision.with(this)
    .detection(new String[]{Detection.SMILE, Detection.MOUTH_OPEN}) // required  
    .delay(2000)  // milliseconds, optional. Default = 1000
    .onSuccessPage(SecondActivity.class) // optional
    .finishOnSuccess(true) // optional, for auto destroy current activity/context after liveness/ocr process.
    .showContour(true)     // optional
    .showLabel(true)       // optional
    .showBoundingBox(true) // optional
    .start();

Customizing String

You can customize instructions and some text by adding the following string resource to your project. Add only the strings you need and make sure the string name is correct, don't be mistaken.

Close Next Loading... Follow instruction: Liveness Detection Identity Type Verification Complete Make sure your face is in the frame and in a well-lit place. Oops! Your face should stay in circle during liveness. We will try again from the beginning. You have successfully followed all instructions, congrats! Please Smile Left Eye Blink Right Eye Blink Look Up Look Down Look Left Look Right Open your Mouth See Last Result Identity Result Scan Identity Scan Identity - KTP Scan Identity - SIM Scan Identity - PASSPORT Selfie holding Identity card Start Verification Take Picture Uploading... Uploading Identity ... Verification succeeded Click the "See Last Result" button to see your verification livenessResult. Your identity is being uploaded and processed by our system, it may take some time. Verification Failed Position your identity card in the frame and in a well-lit place. ">

<string name="kv_title_close" translatable="false">Closestring>
<string name="kv_title_next" translatable="false">Nextstring>
<string name="kv_msg_loading_data" translatable="false">Loading...string>


<string name="kv_title_instruction" translatable="false">Follow instruction:string>
<string name="kv_title_liveness" translatable="false">Liveness Detectionstring>
<string name="kv_title_identity_type" translatable="false">Identity Typestring>
<string name="kv_msg_verification_complete" translatable="false">Verification Completestring>


<string name="kv_clue_yourface_inframe" translatable="false">Make sure your face is in the frame and in a well-lit place.
string>


<string name="kv_msg_yourface_out_circle" translatable="false">Oops! Your face should stay in circle during liveness. We will try again from the beginning.string>
<string name="kv_msg_liveness_oncomplete" translatable="false">You have successfully followed all instructions, congrats!
string>


<string name="kv_smile" translatable="false">Please Smilestring>
<string name="kv_left_eye_blink" translatable="false">Left Eye Blinkstring>
<string name="kv_right_eye_blink" translatable="false">Right Eye Blinkstring>
<string name="kv_look_up" translatable="false">Look Upstring>
<string name="kv_look_down" translatable="false">Look Downstring>
<string name="kv_look_left" translatable="false">Look Leftstring>
<string name="kv_look_right" translatable="false">Look Rightstring>
<string name="kv_open_mouth" translatable="false">Open your Mouthstring>


<string name="kv_title_ocr_last_result" translatable="false">See Last Resultstring>
<string name="kv_title_identity_result" translatable="false">Identity Resultstring>
<string name="kv_title_scan_identity" translatable="false">Scan Identitystring>
<string name="kv_title_scan_ktp" translatable="false">Scan Identity - KTPstring>
<string name="kv_title_scan_sim" translatable="false">Scan Identity - SIMstring>
<string name="kv_title_scan_passport" translatable="false">Scan Identity - PASSPORTstring>
<string name="kv_title_hand_held" translatable="false">Selfie holding Identity cardstring>
<string name="kv_title_ocr_start" translatable="false">Start Verificationstring>
<string name="kv_title_ocr_take_picture" translatable="false">Take Picturestring>
<string name="kv_title_ocr_uploading" translatable="false">Uploading...string>
<string name="kv_msg_upload_identity" translatable="false">Uploading Identity ...string>
<string name="kv_msg_ocr_succeded" translatable="false">Verification succeededstring>
<string name="kv_msg_ocr_see_result" translatable="false">Click the "See Last Result" button to see your verification livenessResult.string>
<string name="kv_msg_upload" translatable="false">Your identity is being uploaded and processed by our system, it may take some time.string>
<string name="kv_msg_ocr_verification_failed" translatable="false">Verification Failedstring>
<string name="kv_clue_card_inframe" translatable="false">Position your identity card in the frame and in a well-lit place.
string>

Next : Advance Implementation >>

You might also like...
Android SDK for eyeson video service incl. demo app

eyeson Android SDK Android SDK for eyeson video service incl. demo app Prerequisites A webservice to host and maintain eyeson meetings is required. Th

Free forever Marketing SDK with a dashboard for in-app SplashScreen banners with built-in analytics
Free forever Marketing SDK with a dashboard for in-app SplashScreen banners with built-in analytics

AdaptivePlus Android SDK AdaptivePlus is the control center for marketing campaigns in mobile applications Requirements minSdkVersion 16 Examples prov

Air Native Extension (iOS and Android) for the Facebook mobile SDK

Air Native Extension for Facebook (iOS + Android) This is an AIR Native Extension for the Facebook SDK on iOS and Android. It has been developed by Fr

AWS SDK for Android. For more information, see our web site:

AWS SDK for Android For new projects, we recommend interacting with AWS using the Amplify Framework. The AWS SDK for Android is a collection of low-le

Countly Product Analytics Android SDK
Countly Product Analytics Android SDK

Countly Android SDK We're hiring: Countly is looking for Android SDK developers, full stack devs, devops and growth hackers (remote work). Click this

Android Real Time Chat & Messaging SDK
Android Real Time Chat & Messaging SDK

Android Chat SDK Overview Applozic brings real-time engagement with chat, video, and voice to your web, mobile, and conversational apps. We power emer

Evernote SDK for Android

Evernote SDK for Android version 2.0.0-RC4 Evernote API version 1.25 Overview This SDK wraps the Evernote Cloud API and provides OAuth authentication

Android Chat SDK built on Firebase
Android Chat SDK built on Firebase

Chat21 is the core of the open source live chat platform Tiledesk.com. Chat21 SDK Documentation Features With Chat21 Android SDK you can: Send a direc

Liquid SDK (Android)

Liquid Android SDK Quick Start to Liquid SDK for Android This document is just a quick start introduction to Liquid SDK for Android. We recommend you

Comments
  • How can I remove the text:

    How can I remove the text: "DEMO"

    Hi team,

    I'm very impressive with your work, I have a question: If I want to modify the liveness layout, how can I remove the text "DEMO" always show in the camera's screen while doing face verification?

    Thanks!

    opened by hungk64it1x 2
Sdk-android - SnapOdds Android SDK

Documentation For the full API documentation go to https://snapodds.github.io/sd

Snapodds 0 Jan 30, 2022
Segmenkt - The SegmenKT Kotlin SDK is a Kotlin-first SDK for Segment

SegmenKT Kotlin SDK The SegmenKT Kotlin SDK is a Kotlin-first SDK for Segment. I

UNiDAYS 0 Nov 25, 2022
Frogo SDK - SDK Core for Easy Development

SDK for anything your problem to make easier developing android apps

Frogobox 10 Dec 15, 2022
HubSpot Kotlin SDK ๐Ÿงบ Implementation of HubSpot API for Java/Kotlin in tiny SDK

HubSpot Kotlin SDK ?? Implementation of HubSpot API for Java/Kotlin in tiny SDK

BOOM 3 Oct 27, 2022
Storyblok Kotlin Multiplatform SDK sample (Android, JVM, JS)

storyblok-mp-SDK-sample *WIP* ... a showcase of the Storyblok Kotlin Multiplatform Client SDK. (Android, JVM, JS, iOS, ...) What's included ?? โ€ข About

Mike Penz 6 Jan 8, 2022
Its measurement app made using kotlin with sceneform sdk by google

ARCORE MEASUREMENT This app is build using sceneform sdk for android using kotlin language It helps you measure the distance between multiple points i

Kashif Mehmood 39 Dec 9, 2022
Project of an sdk user, for default implementations of login/register user

Login_Manager Project of an sdk user, for default implementations of login/register user Implementation For use, is necessary: configure the feature c

null 0 Feb 5, 2022
Peer Support is a community-based peer to peer mental health therapy platform built using Webex Android SDK

Peer Support Peer Support is a community-based peer to peer mental health therapy platform built using Webex Android SDK. Table of Contents Video Demo

Webex Solution Developers 1 Sep 6, 2022
This App is sending Face capture data over network, built around the latest Android Arcore SDK.

AndroidArcoreFacesStreaming From any Android phone ArCore compatible, using this app will send over TCP 5680 bytes messages: The first 5616 bytes is a

Maxime Dupart 30 Nov 16, 2022
How to Integrate SAWO SDK to an Android app

How to Integrate SAWO SDK to an Android app Add following line to root build.gradle repositories block maven { url 'https://jitpack.io' } Add this to

Latiful Mousom 0 Nov 20, 2021