Image helper SDK
December 9th, 2022
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:
- Use
ImageHelperOptions.Builder.enableAadhaarMasking()
to can get masked aadhaar photo - Using
ImageHelperOptions.Builder.setPhotoOptions()
use can choose whether you want to take just selfie, just document images or both.
Use one of the followingImageHelperOptions.PhotoOptions.SELFIE_ONLY
,ImageHelperOptions.PhotoOptions.DOC_PHOTO_ONLY
orImageHelperOptions.PhotoOptions.SELFIE_WITH_DOC_PHOTO
- To set Document type use
ImageHelperOptions.Builder.setDocumentType()
. Currently we support only these document typesDocumentType.AADHAAR
,DocumentType.PAN
,DocumentType.DRIVER_LICENSE
andDocumentType.VOTER_ID
. - To enable or disable image from gallery option use
ImageHelperOptions.Builder.setGalleryOption()
.
Use one of the followingImageHelperOptions.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 useImageHelperOptions.GalleryOption.ALLOW
, by default it is enabled in all screens. - By default the SDK supports both side of documents to be captured. To override the behaviour you can use either
ImageHelperOptions.Builder.enableOnlyBackDoc()
orImageHelperOptions.Builder.enableOnlyFrontDoc()
which allows one screen. - To allow the SDK to give option to switch camera during a selfie journey use the option
ImageHelperOptions.Builder.enableSwitchCameraInSelfie()
- 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:
- Selfie file path
imageHelperResult.getSelfieResult().getSelfiePath()
- Document front image file path
imageHelperResult.getDocumentResult().getDocFrontPath()
- Document back image file path
imageHelperResult.getDocumentResult().getDocBackPath()
- Glare in front document image
imageHelperResult.getDocumentResult().isGlareInFront()
- Glare in back document image
imageHelperResult.getDocumentResult().isGlareInBack()
- Blur in front document image
imageHelperResult.getDocumentResult().isBlurInFront()
- Blur in back document image
imageHelperResult.getDocumentResult().isBlurInBack()
- Face in document in front document image
imageHelperResult.getDocumentResult().isFaceInDoc()
- Doc clarity in front document image
imageHelperResult.getDocumentResult().isDocFrontClear()
- 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);
}
}