Code Monkey home page Code Monkey logo

ekyc-id-android's Introduction

ekyc-logo

EkycID SDK for Android


The EkycID Android SDK lets you build a fantastic OCR and Face Recognition experience in your Android app.

With one quick scan, your users will be able to extract information from their identity cards, passports, driver licenses, license plates, vehicle registration, COVID-19 vaccination card, and any other government-issued document.

EkycID is:

  • Easy to integrate into existing ecosystems and solutions through the use of SDKs that support both native and hybrid applications.
  • Better for user experience because the document detection and liveness checks are done directly offline on the device.
  • Great for cutting down operations costs and increasing efficiency by decreasing reliance on human labor and the time needed for manual data entry.

EkycID can:

  • Extract information from identity documents through document recognition & OCR.
  • Verify whether an individual is real or fake through liveness detection, and face recognition.
  • Verify the authenticity of the identity documents by combining the power of document detection, OCR, liveness detection, and face recognition.

To see all of these features at work, download our free demo app:

Get it on Google Play

1. Requirements

  • minSdkVersion: 21
  • targetSdkVersion: 33
  • compileSdkVersion: 33

2. Installation

Step 1: Add the JitPack repository to your root build.gradle at the end of repositories.

allprojects {
     repositories {
          ...
          maven { url 'https://jitpack.io' }
     }
}

Step 2: Add the dependency.

dependencies {
     implementation 'com.github.EKYCSolutions:ekyc-id-android:1.0.21'
}

3. Usage

3.1. Document Scanner

Step 1: Initialize Initializer class and called initializer.start() in onResume.

class MainActivity : AppCompatActivity() {
    val initializer = Initializer(this)

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
    }

    @RequiresApi(Build.VERSION_CODES.N)
    override fun onResume() {
        super.onResume()
        
        // Start initializer here
        initializer.start {
            
        }
    }
}

Step 2: Add DocumentScannerCameraView to your layout.xml

<com.ekycsolutions.ekycid.documentscanner.DocumentScannerCameraView
      android:id="@+id/documentScannerCameraView
      android:layout_width="match_parent"
      android:layout_height="match_parent" />

Step 3: Initialize DocumentScannerCameraView and implements DocumentScannerEventListener.

class MainActivity : AppCompatActivity(), DocumentScannerEventListener {
    val initializer = Initializer(this)

    lateinit var documentScannerView: DocumentScannerCameraView

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
    }

    @RequiresApi(Build.VERSION_CODES.N)
    override fun onResume() {
        super.onResume()
        initializer.start {
            runOnUiThread {
                setContentView(R.layout.activity_main)
                documentScannerView = findViewById(R.id.documentScannerView)
                documentScannerView.addListener(this)
                documentScannerView.setWhiteList(arrayListOf(ObjectDetectionObjectType.NATIONAL_ID_0.name))
                documentScannerView.start()
            }
        }
    }

    override fun onInitialize() {
        Log.d(TAG, "onInitialize")
    }

    override fun onFrame(frameStatus: FrameStatus) {
        if (frameStatus != FrameStatus.PROCESSING) {
            Log.d(TAG, "onFrame: $frameStatus")
        }
    }

    override fun onDetection(detection: DocumentScannerResult) {
        Log.d(TAG, "onDetection")
    }
}

3.2. Liveness Detection

Step 1: Initialize Initializer class and called initializer.start() in onResume.

class MainActivity : AppCompatActivity() {
    val initializer = Initializer(this)

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
    }

    @RequiresApi(Build.VERSION_CODES.N)
    override fun onResume() {
        super.onResume()
        
        // Start initializer here
        initializer.start {
            
        }
    }
}

Step 2: Add DocumentScannerCameraView to your layout.xml

<com.ekycsolutions.ekycid.livenessDetection.LivenessDetectionCameraView
      android:id="@+id/livenessDetectionCameraView
      android:layout_width="match_parent"
      android:layout_height="match_parent" />

Step 3: Initialize LivenessDetectionCameraView and implements LivenessDetectionEventListener.

class MainActivity : AppCompatActivity(), LivenessDetectionEventListener {
    val initializer = Initializer(this)

    lateinit var livenessDetectionCameraView: LivenessDetectionCameraView

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
    }

    @RequiresApi(Build.VERSION_CODES.N)
    override fun onResume() {
        super.onResume()
        initializer.start {
            runOnUiThread {
                setContentView(R.layout.activity_main)
                livenessDetectionCameraView = findViewById(R.id.documentScannerView)
                livenessDetectionCameraView.addListener(this)
                livenessDetectionCameraView.setOptions(
                    LivenessDetectionOptions(
                         arrayListOf(LivenessPrompt.LOOK_LEFT, LivenessPrompt.LOOK_RIGHT, LivenessPrompt.BLINKING)
                    )
                )
                livenessDetectionCameraView.start()
            }
        }
    }

    override fun onInitialize() {
        Log.d(TAG, "onInitialize")
    }

    override fun onFrame(frameStatus: FrameStatus) {
        if (frameStatus != FrameStatus.PROCESSING) {
            Log.d(TAG, "onFrame: $frameStatus")
        }
    }

    override fun onPromptCompleted(completedPromptIndex: Int, success: Boolean: progress: Float) {
        Log.d(TAG, "onPromptCompleted")
    }
    
    override fun onAllPromptsCompleted(detection: LivenessDetectionResult) {
        Log.d(TAG, "onAllPromptsCompleted")
    }
    
    override fun onFocus() {
        Log.d(TAG, "onFocus")
    }
    
    override fun onFocusDropped() {
        Log.d(TAG, "onFocusDropped")
    }
    
    override fun onCountDownChanged(current: Int, max: Int) {
        Log.d(TAG, "onCountDownChanged")
    }
}

3.3. Perform Face Compare and OCR

To perform face compare and ocr, you can call your server that integrated with our NodeSDK to get face compare score and ocr response respectively.

3.4 Blur Detection

This section outlines the Canny Edge Detection algorithm that is used to detect bluriness in scanning the documents.

The Canny Edge Detection algorithm is a popular method for detecting edges in digital images. An edge is a boundary or transition region between two different regions or objects in an image. It represents a significant change in pixel intensity or color values. Less pronounced or fewer detected edges in an image can indicate blurriness or a lack of sharp transitions between objects or regions, hence why this algorithm was chosen.

Given an image, here are the steps performed on it to determine blurriness:

  1. Warp the image using the perspective transformation matrix to obtain a cropped and transformed image.

warped

  1. Convert the warped image to grayscale.
  2. Apply Gaussian blur to the grayscale image.

grey

  1. Perform Canny Edge Detection on the original image. This will produce an output which we will call the edge image.

edges

  1. Calculate the height and width of the edge image.
  2. Count the number of white pixels in the edge image.
  3. Calculate the ratio of white pixels to the total number of pixels of the image ( width * height )
  4. If the calculated ratio is less than or equal to the set ratio, the image is determined to be blurry.

4. Contact

For any other questions, feel free to contact us at ekycsolutions.com

5. License

© 2022 EKYC Solutions Co, Ltd. All rights reserved.

ekyc-id-android's People

Contributors

chungphing avatar finamuune avatar khemraksa avatar socret360 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.