Issue with scanning the QR code present in Indian aadhaar card

Skip to first unread message

Kishan Kumar

Aug 21, 2018, 8:32:16 PM8/21/18
to zxing
I am trying to decode the QR code present in the Indian aadhar card using Zxing API for the customer uploaded aadhar image on our website.

I am able to decode the QR code if its big in size and get the complete XML data. However the QR codes which are small in size are not getting decoded as QR codes. They are getting decoded as BarcodeFormat.UPC_E, which is a one dimensional bar code unlike QR code which is two dimensional. So the output for small QR codes is coming something like this 04400621, instead of the expected XML output. This is happening with the online tool as well.

Some small QR codes are getting decoded by the online tool if we crop just the QR code part of the aadhar but the API fails to decode if we pass the cropped part of the small images.

I am using below API present in class

Result decode(BinaryBitmap image, Map hints)

Putting breakpoints in MultiFormatReader library, I could see that QRCodeReader is not able to decode the QR code, however MultiFormatOneDReader is able to decode the same.

Hence the small QR codes are getting decoded as BarcodeFormat.UPC_E it seems.

Pasting the code snippet below:

String filePath = "xyz";
File file = new File(filePath);
FileInputStream fileInputStream = new FileInputStream(filePath);
BufferedImage bufferedImage =;

LuminanceSource bufferedImageLuminanceSource = new BufferedImageLuminanceSource(bufferedImage);
BinaryBitmap binaryBitmap = new BinaryBitmap(new HybridBinarizer(bufferedImageLuminanceSource));

Map<DecodeHintType, Object> tmpHintsMap = new EnumMap<DecodeHintType, Object>(
tmpHintsMap.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);
tmpHintsMap.put(DecodeHintType.CHARACTER_SET, "ISO-8859-1");
tmpHintsMap.put(DecodeHintType.PURE_BARCODE, Boolean.FALSE);(tried with and without this option)

Result result = new MultiFormatReader().decode(binaryBitmap, tmpHintsMap);

Lachezar Dobrev

Aug 27, 2018, 8:49:22 AM8/27/18
to, zxing
You're (probably) getting a False-Positive with UPC or Code-39 or
another 1D bar-code type.
> --
> You received this message because you are subscribed to the Google Groups "zxing" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> For more options, visit


Aug 30, 2018, 9:54:58 PM8/30/18
Hi Lachezar,

Thanks for your response.
But I had already tried that.
Zxing is not able to decode the small QR codes on passing BarcodeFormat.QR_CODE and is throwing the exception:

The problem is that even the online tool  is not able to decode small QR codes.


Lachezar Dobrev

Aug 31, 2018, 8:21:30 AM8/31/18
to Kishan Kumar, zxing
If possible can you share one of these? It might be any of a
thousand reasons why the code is not recognised.

Typically though I'd suggest that you try slightly fiddling with the
image: scaling up and down, applying various blurs, applying various
sharpening. ZXing is designed to handle streams of images, and is not
a sure-shot solution when you only have one frame/image to work with.
Instead ZXing works at significantly less than 100% accuracy, but
works fast so that streams can be processes real-time. When there is
no stream, you can simulate one (by applying various modifications to
generate "frames").


Aug 31, 2018, 9:14:11 PM8/31/18
Here is a sample aadhaar image which doesn't work -
Its taken from this post where someone had posted the same issue some time back with Indian aadhaar cards. The image of the QR code on an Indian aadhaar card is too small as can be seen from the above image. 
Reply all
Reply to author
0 new messages