解码Android应用程序中的QR码?

在Android中,使用ZXing,我们可以通过手机摄像头扫描QR码并对其进行解码。

但是,在我的场景中,QR码图像存储在手机本身,我需要解码它。

无论如何以这种方式解码QR图像?

您可以使用ZXing代码。

查看DecodeHandler.java 。

您可以简单地使用Mobile Vision API从Image中解码QR码。它非常准确,可以在图像上检测多个Qr代码。

您必须包含以下库才能使用Mobile Vision API:

编译’com.google.android.gms:play-services-vision:9.6.1′

BarcodeDetector detector = new BarcodeDetector.Builder(context) .setBarcodeFormats(Barcode.DATA_MATRIX | Barcode.QR_CODE) .build(); if(!detector.isOperational()){ Log.d("QR_READ","Could not set up the detector!"); } Frame frame = new Frame.Builder().setBitmap(bitmap).build(); SparseArray barcodes = detector.detect(frame); Log.d("QR_READ","-barcodeLength-"+barcodes.size()); Barcode thisCode=null; if(barcodes.size()==0){ Log.d("QR_VALUE","--NODATA"); } else if(barcodes.size()==1){ thisCode = barcodes.valueAt(0); Log.d("QR_VALUE","--"+thisCode.rawValue); } else{ for(int iter=0;iter