1

我是第 8 面墙和前端开发的新手。我正在开发一个项目,其中包含在框架中开发的一堆图像目标体验。最重要的是,我需要在 AR 中扫描二维码。根据我在文档中看到的内容,我可以添加相机管道模块。但我的问题是,我怎样才能开始使用框架组件寄存器来实现它?起始代码在这里。

AFRAME.registerComponent('qr-scan', {
  schema: {
  },
  init: function () {
    // Install a module which gets the camera feed as a UInt8Array.
    XR8.addCameraPipelineModule(
    XR8.CameraPixelArray.pipelineModule({luminance: true, width: 240, height: 320}))
    // Install a module that draws the camera feed to the canvas.
    XR8.addCameraPipelineModule(XR8.GlTextureRenderer.pipelineModule())
    // Create our custom application logic for scanning and displaying QR codes.
    XR8.addCameraPipelineModule({
      name : 'qrscan',
      onProcessCpu : ({onProcessGpuResult}) => {
        // CameraPixelArray.pipelineModule() returned these in onProcessGpu.
        const { pixels, rows, cols, rowBytes } = onProcesGpuResult.camerapixelarray
        const { wasFound, url, corners } = findQrCode(pixels, rows, cols, rowBytes)
        return { wasFound, url, corners }
      },
      onUpdate : ({onProcessCpuResult}) => {
        // These were returned by this module ('qrscan') in onProcessCpu
        const {wasFound, url, corners } = onProcessCpuResult.qrscan
        if (wasFound) {
          showUrlAndCorners(url, corners)
        }
      },
    })
  },
})
4

0 回答 0