【问题标题】:QR Code Scanning inside a limit area限制区域内的二维码扫描
【发布时间】:2018-03-13 22:22:06
【问题描述】:

我是安卓新手。我通过以下链接使用 Google vision-api 依赖项进行二维码扫描:

https://www.youtube.com/watch?v=INVNULTm56o.

但它扫描整个屏幕。如果我想在不最小化屏幕的情况下从限制区域或边界读取二维码,可以吗?让我知道谢谢。

我在我的应用程序中设计了这个边界,我只想从边界读取二维码:-

【问题讨论】:

标签: android


【解决方案1】:

您可以将 Zxing Library 用于 QR-code Scanner 以及 Barcode Scanner

如果您想自定义布局:

您还可以使用此库处理onCreate()onResume()onPause()

build.gradle(Module:app) 文件

compile 'me.dm7.barcodescanner:zxing:1.9'

Java 代码 ScanActivity

public class ScanActivity extends AppCompatActivity implements ZXingScannerView.ResultHandler{

private ZXingScannerView mScannerView;

@Override
public void onCreate(Bundle state) {
    super.onCreate(state);
    mScannerView = new ZXingScannerView(this);   // Programmatically initialize the scanner view
    setContentView(mScannerView);                // Set the scanner view as the content view
}

@Override
public void onResume() {
    super.onResume();
    mScannerView.setResultHandler(this); // Register ourselves as a handler for scan results.
    mScannerView.startCamera();          // Start camera on resume
}

@Override
public void onPause() {
    super.onPause();
    mScannerView.stopCamera();           // Stop camera on pause
}

@Override
public void handleResult(Result rawResult) {
    // Do something with the result here
    Log.v("tag", rawResult.getText()); // Prints scan results
    Log.v("tag", rawResult.getBarcodeFormat().toString()); // Prints the scan format (qrcode, pdf417 etc.)



    // If you would like to resume scanning, call this method below:
    //mScannerView.resumeCameraPreview(this);
}
}

您将在以下位置获得扫描仪结果:

@Override
public void handleResult(Result rawResult) {
    // Do something with the result here
     Log.v("tag", rawResult.getText()); // Prints scan results
     Log.v("tag", rawResult.getBarcodeFormat().toString()); // Prints the scan format (qrcode, pdf417 etc.)



    // If you would like to resume scanning, call this method below:
    //mScannerView.resumeCameraPreview(this);
}

【讨论】:

    猜你喜欢
    • 2018-09-27
    • 1970-01-01
    • 1970-01-01
    • 2019-06-12
    • 1970-01-01
    • 2022-08-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多