【问题标题】:Trouble when getting ARCore image frame to feed QRCode Scanner获取 ARCore 图像帧以馈送 QRCode 扫描仪时出现问题
【发布时间】:2020-04-06 04:38:06
【问题描述】:

我一直在使用 ARCore 构建应用程序,让用户分别扫描 QRCode 和渲染 3D 对象。我尝试使用 AugmentedImage 来识别 QRCode,但效果不佳,因为 QR 码的差异对于 ARCore 的识别并不真正重要。

我想在一个模块中将 QRCode Scanner(使用 ZXing lib 或 Google Vision API)集成到 ARCore,利用 ARCore 框架。

https://github.com/google-ar/sceneform-android-sdk/issues/43 我试过这个,但是当我处理灰度时,它遇到了缓冲区不够大的问题......请帮忙!

我的代码:

@Override
public void onUpdate(FrameTime frameTime) {
    // delegate this frame to cloud session to process
    if (this.cloudSession != null) {
        this.cloudSession.processFrame(mSceneView.getArFrame());
    }

    Frame frame = mSceneView.getArFrame();
    if (null == frame) return;
    try (Image image = frame.acquireCameraImage()) {
        if (image.getFormat() != ImageFormat.YUV_420_888) {
            throw new IllegalArgumentException(
                    "Expected image in YUV_420_888 format, got format " + image.getFormat());
        }

        ByteBuffer processedImageBytesGrayscale =
                edgeDetector.detect(
                        image.getWidth(),
                        image.getHeight(),
                        image.getPlanes()[0].getRowStride(),
                        image.getPlanes()[0].getBuffer());

        Bitmap bitmap = Bitmap.createBitmap(image.getWidth(), image.getHeight(),
                Bitmap.Config.ARGB_8888);
        processedImageBytesGrayscale.rewind();
        bitmap.copyPixelsFromBuffer(processedImageBytesGrayscale);


        String code = QRCodeHelper.detectQRCode(this, bitmap);
        if (code != null) {
            runOnUiThread(() -> tvScanningResult.setText(code));
        }

    } catch (Exception e) {
        Log.e(TAG, "Exception copying image", e);
    }
}

【问题讨论】:

    标签: android graphics arcore


    【解决方案1】:

    而不是

    Bitmap bitmap = Bitmap.createBitmap
    image.getWidth(),
    image.getHeight(),
    Bitmap.Config.ARGB_8888);
    

    试试

            Bitmap bitmap = Bitmap.createBitmap(
                    image.getWidth(),
                    image.getHeight(),
                    Bitmap.Config.ALPHA_8);
    

    【讨论】:

      猜你喜欢
      • 2015-05-02
      • 2010-09-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-17
      • 2022-08-07
      • 1970-01-01
      相关资源
      最近更新 更多