BlinkID / blinkid-android

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

How can I get the bitmap after scanned ID Document #6

Closed pnlgcoding closed 7 years ago

pnlgcoding commented 8 years ago

I used the function of ID Document in BlinkIdDemo, it's worked perfect. But I want to get the bitmap of card when it's return the result, so how can I do it? I tried put the Extra_Output in intent but it's not working :( Intent intent = mElements[position].getScanIntent(); url = getURL(); intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(url)));

i1E commented 8 years ago

Hi longph92, to get the image, you first have to enable this option in recognizer that you use, for example if you use MRTD recognizer, you should use method setShowFullDocument:

 ...
 MRTDRecognizerSettings mrtd = new MRTDRecognizerSettings();
 // set to true to obtain images containing full document
 mrtd.setShowFullDocument(true);
 ...

When you are creating the intent for one of the provided scan activities, you have to send the ImageListener and desired ImageMetadataSettings:

 Intent intent = new Intent(this, ScanCard.class);
 ...
 MetadataSettings.ImageMetadataSettings ims = new MetadataSettings.ImageMetadataSettings();
 // sets whether image that was used to obtain valid scanning result will be available
 ims.setSuccessfulScanFrameEnabled(true);
 intent.putExtra(ScanActivity.EXTRAS_IMAGE_METADATA_SETTINGS, ims);
 intent.putExtra(ScanActivity.EXTRAS_IMAGE_LISTENER, new MyImageListener());
 ...

You can find more information and an example how to implement ImageListener in our documentation.

When you obtain the image, you can use convertToBitmap() method to get the bitmap.

pnlgcoding commented 8 years ago

Hi @i1E , It's returned the result but I don't know why the bitmap cannot save to sdcard, it's always throws FileNotFoundException. I had tried many method to save the bitmap but still not work :(. So thank for your answers, it's helpful :+1:

pnlgcoding commented 8 years ago

Hi @i1E , I had found the issue from my device on 6.0, it's denied the permission to write to sdcard. So now I want to crop the card only instead of full image. So is it possible?

i1E commented 8 years ago

Hi, to save bitmap to sdcard, you have to obtain permissions for external storage. If you use API level >= 23, working with permissions is described here.

To get dewarped(cropped) images, you have to enable that option in ImageMetadataSettings by using setDewarpedImageEnabled method.

...
MetadataSettings.ImageMetadataSettings ims = new MetadataSettings.ImageMetadataSettings();
// sets whether image that was used to obtain valid scanning result will be available
// don't enable this, if you want only dewarped(cropped) images
// ims.setSuccessfulScanFrameEnabled(true);

// sets whether dewarped(cropped) image should be available in MetadataListener
ims.setDewarpedImageEnabled(true);
...
pnlgcoding commented 8 years ago

Hi @i1E , It's worked perfect, thank you so much. The BlinkID just only support scan German and UK driver's licenses right? Because my project need to scan a French driver's license.

i1E commented 8 years ago

Hi @longph92 , for now, it is possible to scan German, UK and US driver's licenses with BlinkID SDK. In the future, we plan to support scanning of driver's licenses from other countries, but at this moment we don't know exactly when we will support the French driver's licenses.

Thanks for your interest.

DoDoENT commented 8 years ago

Hi @longph92,

currently BlinkID supports only scanning of US Driver's License 2D barcodes, MRZ documents (passports and IDs containing machine readable zone), german and UK driver's licences.

If you could provide us with examples of French driver's licences, we would be happy to add support for them (we do not have any samples, so we cannot add support blindly).

We will not share any private data found on these licenses - the images of licences will only be used to develop data extraction methods needed to add 1st class support for French driver's licences. You can send images of French driver's licences samples to android-devs@microblink.com.

DoDoENT commented 8 years ago

Hi @longph92,

can we close this issue?

DoDoENT commented 8 years ago

Hi @i1E , I'm very interesting with blinkID and now I'm implementing the demo project with scan France and Mexican. So how can I setting for each country? it's means the user can be scan 1 type of card only at the moment.

Hi @longph92! French and Mexican IDs and driver's licences are currently not supported out of the box. However, since v2.6.0 we added support for Templating API which gives you possibility to add support for custom documents. Here you can find two examples of how Templating API could be used to add support for Croatian ID cards. You can use the same approach for Mexican and French documents.