Вы можете просто использовать API Mobile Vision для декодирования QR-кода из изображения. Он очень точный и может обнаружить более одного кода Qr на изображении.
Для использования необходимо включить следующий порядок библиотекAPI Mobile Vision:
compile '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);
}
}