BlinkID / blinkid-android

Everything you need to add AI-driven ID scanning into your native Android app.
https://microblink.com/identity/identity-document-scanning/
441 stars 153 forks source link

Support for UAE emirates ID #66

Closed jihadrhamza closed 6 years ago

jihadrhamza commented 6 years ago

Can someone please help me to get face image from the front side of the card along with details from the back side of the card? Used sample code for MRTD Combined version. But not able to retrieve the face image.

As per the documentation in this link https://github.com/BlinkID/blinkid-android#mrtdCombined, It says to use MRTDCombinedRecognizerSettings for taking face image from the ID.

But as per the issue https://github.com/BlinkID/blinkid-android/issues/55, It says to use DocumentFaceRecognizer since it is not supported.

How should I know UAE card is supported in this SDK? (app store blinkID application has support for UAE - https://play.google.com/store/apps/details?id=com.microblink.blinkidapp)

Can I use MRTD Combined option for that or DocumentFaceRecognizer?

i1E commented 6 years ago

Hi @jihadrhamza,

you should use MRTDCombinedRecognizer. There are two options for obtaining document images, in your case face image. If you are using provided VerificationFlowActivity you can obtain face image in the following ways:

Assume that you have created intent for the VerificationFlowActivity:

Intent intent = new Intent(this, VerificationFlowActivity.class);
intent.putExtra(VerificationFlowActivity.EXTRAS_LICENSE_KEY, "<your_license_key>");
// ...

1) Obtaining images as metadata

When you are creating MRTDCombinedRecognizerSettings enable returning of face image:

MRTDCombinedRecognizerSettings mrtdCombined = new MRTDCombinedRecognizerSettings();
mrtdCombined.setReturnFaceImage(true);

// pass combined recognizer settings to VerificationFlowActivity
intent.putExtra(VerificationFlowActivity.EXTRAS_COMBINED_RECOGNIZER_SETTINGS, mrtdCombined);

also you have to enable returning of dewarped(cropped) images through metadata in ImageMetadataSettings (because face image is dewarped image):

MetadataSettings.ImageMetadataSettings ims = new MetadataSettings.ImageMetadataSettings();
ims.setDewarpedImageEnabled(true);

// pass image metadata settings to VerificationFlowActivity
intent.putExtra(VerificationFlowActivity.EXTRAS_IMAGE_METADATA_SETTINGS, ims);

// pass your image listener implementation to VerificationFlowActivity
intent.putExtra(VerificationFlowActivity.EXTRAS_IMAGE_LISTENER,  new MyImageListenerImplementation());

you can find more information about obtaining images with ImageListener here.

2) Obtaining images in RecognitionResult

When you are creating MRTDCombinedRecognizerSettings, enable encoding of face image into RecognitionResult:

MRTDCombinedRecognizerSettings mrtdCombined = new MRTDCombinedRecognizerSettings();
mrtdCombined.setEncodeFaceImage(true);

// pass combined recognizer settings to VerificationFlowActivity
intent.putExtra(VerificationFlowActivity.EXTRAS_COMBINED_RECOGNIZER_SETTINGS, mrtdCombined);

Recognition result which contains encoded image cannot be parcelized and passed by Intent extras because of Android limitations on intent extras size. Because of that, you have to obtain RecognitionResult by using the ParcelableScanResultListener. In that case you will not obtain RecognitionResult in onActivityResult() method.

// pass your ParcelableScanResultListener implementation to VerificationFlowActivity
intent.putExtra(VerificationFlowActivity.EXTRAS_SCAN_RESULT_LISTENER, new MyScanResultListener());

In your implementation of onScanningDone(RecognitionResults) method of ParcelableScanResultListener, you can obtain byte[] array of encoded face image from the MRTDCombinedRecognitionResult in the following way:

 // mrtdCombinedRecognitionResult is instance of MRTDCombinedRecognitionResult
 byte[] faceImageJPEGencoded = mrtdCombinedRecognitionResult.getEncodedFaceImage();
jihadrhamza commented 6 years ago

@i1E , Thanks for the answer. Now am able to get the front image along with MRZ details.