在安卓系统中,使用ZXing,我们可以通过手机摄像头扫描二维码并进行解码。
但是,在我的场景中,二维码图像存储在手机本身中,我需要对其进行解码。
有没有办法以这种方式解码QR图像?
发布于 2011-03-03 02:02:46
您可以使用ZXing代码来实现此目的。
查看DecodeHandler.java。
发布于 2016-11-11 16:20:13
您可以简单地使用Mobile Vision API来解码来自Image.It的二维码,该方法非常准确,并且可以在图像上检测到多个二维码。
您必须包含以下库才能使用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<Barcode> 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<barcodes.size();iter++) {
thisCode = barcodes.valueAt(iter);
Log.d("QR_VALUE","--"+thisCode.rawValue);
}
}https://stackoverflow.com/questions/5171294
复制相似问题