扫描印度aadhar卡中存在的QR码的问题

问题描述 投票:1回答:1

我正在尝试使用Zxing API解码印度aadhar卡中的QR码,以便客户在我们的网站上上传aadhar图像。

我能够解码QR码,如果它的大小,并获得完整的XML数据。然而,尺寸小的QR码不会被解码为QR码。它们被解码为BarcodeFormat.UPC_E,这是一维条码,不像QR码是二维的。所以小QR码的输出就像这个04400621,而不是预期的XML输出。这也发生在在线工具https://zxing.org/w/decode.jspx上。

如果我们只裁剪aadhar的QR码部分,那么一些小的QR码会被在线工具解码,但如果我们通过小图像的裁剪部分,则API无法解码。

我在com.google.zxing.MultiFormatReader类中使用以下API

结果解码(BinaryBitmap图像,地图提示)

将断点放在MultiFormatReader库中,我可以看到QRCodeReader无法解码QR码,但MultiFormatOneDReader能够对其进行解码。

因此,小QR码被解码为BarcodeFormat.UPC_E。

粘贴下面的代码片段:

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

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

   Map<DecodeHintType, Object> tmpHintsMap = new EnumMap<DecodeHintType, Object>(
           DecodeHintType.class);
   tmpHintsMap.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);
   tmpHintsMap.put(DecodeHintType.POSSIBLE_FORMATS,
           EnumSet.allOf(BarcodeFormat.class));
   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);
qr-code zxing aadhaar
1个回答
0
投票

尝试使用zbar库(Link here,它适用于较大的QR码

© www.soinside.com 2019 - 2024. All rights reserved.