我正在尝试解码二维码存在于印度Aadhar卡使用Zxing API为客户上传到我们的网站上的aadhar图像。
我能够解码二维码,如果它很大,并获得完整的XML数据。然而,尺寸较小的QR码不会被解码为QR码。他们被解码为BarcodeFormat.UPC_E,这是一个一维条形码,而QR码不是二维的。因此,小二维码的输出类似于04400621,而不是预期的XML输出。在线工具https://zxing.org/w/decode.jspx也是如此。
如果我们只裁剪aadhar的二维码部分,一些小的二维码将被在线工具解码,但如果我们通过小图像的裁剪部分,API将无法解码。
我在com.google.zxing.MultiFormatReader类中使用下面的API
结果解码(BinaryBitmap图像,映射提示)
将断点放在MultiFormatReader库中,我可以看到QRCodeReader无法解码二维码,但MultiFormatOneDReader可以解码相同的二维码。
因此,这些小的二维码似乎被解码成了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);发布于 2019-11-26 13:50:51
Aadhaar使用安全的二维码,出于安全原因,二维码是加密的。Link for more details
现在我们可以使用UIDAI’s windows based application读取安全的二维码。
发布于 2019-03-02 15:31:19
尝试使用zbar库(Link here它在较大的二维码上工作得很好
https://stackoverflow.com/questions/51946533
复制相似问题