带Zxing的条码检测器

问题描述:

我尝试实施条码扫描器。我使用zxing库。我已经尝试从图像扫描qrcode,它的工作原理。带Zxing的条码检测器

我的解码的代码是在这里:

BarcodeDetector barcodeDetector = 
      new BarcodeDetector.Builder(this) 
        .setBarcodeFormats(Barcode.QR_CODE) 
        .build(); 

    Frame myFrame = new Frame.Builder() 
      .setBitmap(myQRCode) 
      .build(); 

    SparseArray<Barcode> barcodes = barcodeDetector.detect(myFrame); 
    if(barcodes.size() != 0) { 
     Log.d("Data: ", barcodes.valueAt(0).displayValue); 
    } else { 
     Log.i("QRError", "No QR data"); 
    } 
} 

另外,我写代码来生成字符串从QR码。但我无法从相机源实现QR扫描仪。我知道我可以通过检测每帧的QR码来完成这项任务。但我认为它会比现有解决方案慢。 zxing是否有解决方案?我不想使用任何三方图书馆。

这是Zxing官方图书馆,它提供了条形码阅读器和生成器以及QR码阅读器和生成器的最佳示例。

Zxing Library

+0

我通过添加'编“com.google.zxing斑马线最新发行版本我的应用程序:核心:3.3.0''。但意图指南的例子不适合我。错误是'No Activity found to handle Intent {act = com.google.zxing.client.android.SCAN(have extras)}' – us2956

+0

给我一点时间,让我为你创建一个例子。 –

+0

https://github.com/dm77/barcodescanner。 这个库使用ZXING作为核心。你可以看看它。它的重量真的很轻。虽然我知道你不会使用第三方 –