Image helper SDK

Image helper SDK

SDK helps to collect pictures of customerID cards & Selfies in a secure manner. It is accompanied by sanity check methods & quality of picture assistance

Minimum Requirements:

minSdkVersion 19
AndroidX

Getting Started:

Add following lines in your root build.gradle

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

Add following lines in your module level build.gradle

dependencies {
    ....
    implementation 'com.github.Invoid-Bureau:imagehelper-on-device-support:0.1.6'
}

This library also uses some common android libraries. If this is not being used, it has to be added in the module level build.gradle

  • androidx.appcompat:appcompat:1.2.0
  • androidx.constraintlayout:constraintlayout:2.0.4
  • com.google.android.material:material:1.3.0
Note:

Since this library is using compiled native code so we recommend to split the apk based on the architecture of the processor to reduce your app size. However, if you are using App Bundle to publish app then you don't have to do anything. Use following code to split the apk.

android {
    splits {
        // Configures multiple APKs based on ABI.
        abi {
            // Enables building multiple APKs per ABI.
            enable true
            // Specifies that we do not want to also generate a universal APK that includes all ABIs.
            universalApk false
        }
    }
}

Initialize SDK:

yourinitbutton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ImageHelperOptions imageHelperOptions = new ImageHelperOptions.Builder()
                  .setPhotoOption(ImageHelperOptions.PhotoOptions.SELFIE_WITH_DOC_PHOTO)
                  .setDocumentType(DocumentType.AADHAAR)
                  .setGalleryOption(ImageHelperOptions.GalleryOption.ALLOW_IN_DOC_ONLY)
                  .build();
              ImageHelper.with(this, imageHelperOptions).start();
            }
        });

Options:

  1. Use ImageHelperOptions.Builder.enableAadhaarMasking() to can get masked aadhaar photo
  2. Using ImageHelperOptions.Builder.setPhotoOptions() use can choose whether you want to take just selfie, just document images or both.
    Use one of the following ImageHelperOptions.PhotoOptions.SELFIE_ONLY, ImageHelperOptions.PhotoOptions.DOC_PHOTO_ONLY or ImageHelperOptions.PhotoOptions.SELFIE_WITH_DOC_PHOTO
  3. To set Document type use ImageHelperOptions.Builder.setDocumentType(). Currently we support only these document types DocumentType.AADHAAR, DocumentType.PAN, DocumentType.DRIVER_LICENSE and DocumentType.VOTER_ID.
  4. To enable or disable image from gallery option use ImageHelperOptions.Builder.setGalleryOption().
    Use one of the following ImageHelperOptions.GalleryOption.ALLOW_IN_DOC_ONLY, ImageHelperOptions.GalleryOption.ALLOW_IN_SELFIE_ONLY to enable or disable in either of the screens. If you want to enable in all the screens then use ImageHelperOptions.GalleryOption.ALLOW, by default it is enabled in all screens.
  5. By default the SDK supports both side of documents to be captured. To override the behaviour you can use either ImageHelperOptions.Builder.enableOnlyBackDoc() or ImageHelperOptions.Builder.enableOnlyFrontDoc() which allows one screen.
  6. To allow the SDK to give option to switch camera during a selfie journey use the option ImageHelperOptions.Builder.enableSwitchCameraInSelfie()
  7. The SDK shows results for post processing done on the image such as glare, blur, doc-number and face aptitude in document. If you don't want such an info to be shown use ImageHlperOptions.Builder.disablePostProcess(). You will still get the result in response this controls the info box only.

Response returned from the SDK:

  1. Selfie file path imageHelperResult.getSelfieResult().getSelfiePath()
  2. Document front image file path imageHelperResult.getDocumentResult().getDocFrontPath()
  3. Document back image file path imageHelperResult.getDocumentResult().getDocBackPath()
  4. Glare in front document image imageHelperResult.getDocumentResult().isGlareInFront()
  5. Glare in back document image imageHelperResult.getDocumentResult().isGlareInBack()
  6. Blur in front document image imageHelperResult.getDocumentResult().isBlurInFront()
  7. Blur in back document image imageHelperResult.getDocumentResult().isBlurInBack()
  8. Face in document in front document image imageHelperResult.getDocumentResult().isFaceInDoc()
  9. Doc clarity in front document image imageHelperResult.getDocumentResult().isDocFrontClear()
  10. Doc clarity in back document image imageHelperResult.getDocumentResult().isDocBackClear()
@Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        if(requestCode == ImageHelper.IMAGE_HELPER_REQ_CODE) {
        
            if(resultCode == RESULT_OK) {
                ImageHelperResult imageHelperResult = data.getParcelableExtra(ImageHelper.IMAGE_RESULT);
                Log.d(TAG, "onActivityResult: "+imageHelperResult.toString());
           
           } else if(resultCode == ImageHelper.AUTHORIZATION_RESULT_CODE) {
           
           int authorizationResult = data.getIntExtra(ImageHelper.AUTHORIZATION_RESULT, -1);
                if(authorizationResult == ImageHelper.UNAUTHORIZED) {
                    Log.d(TAG, "onActivityResult: unauthorized");
                } else {
                    Log.d(TAG, "onActivityResult: authorization error");
                }
            }
        } else {
            super.onActivityResult(requestCode, resultCode, data);
        }
    }