1

我想在多个图像上增强视频。所以我正在尝试用多个图像实现第 8 壁图像跟踪增强。但我无法获得增强。我对图像目标有疑问。如果我在 html 中提到图像目标名称,那么它可以工作。

<a-entity target-video="name: imageTargets; video: #alpha-video;" material="shader: chromakey; src: #alpha-video; color: 0.1 0.9 0.2" geometry="primitive: plane; height: 0.6; width: 1.38;"> </a-entity>

名称:imagetarget1(第 8 壁控制台中的图像目标名称之一)

但是当我尝试使用多个图像时,它就不起作用了。谁能帮我解决这个问题。我在第 8 个壁挂式控制台中上传了 10 张图像,名称如下 - 'imagetarget1'、'imagetarget2'、'imagetarget3'、'imagetarget4'、'imagetarget5'、'imagetarget6'、'imagetarget7'、'imagetarget8'、'imagetarget9 ', 'imagetarget10' 。

AFRAME.registerComponent('target-video', {
  schema: {
    name: {
      type: 'string'
      XR8.XrController.configure({
        imageTargets: ['imagetarget1', 'imagetarget2', 'imagetarget3', 'imagetarget4', 'imagetarget5', 'imagetarget6', 'imagetarget7', 'imagetarget8', 'imagetarget9', 'imagetarget10']
      })
    },
    video: {
      type: 'string'
    },
  },
  init: function() {
    const object3D = this.el.object3D
    const name = this.data.name
    object3D.visible = false
    const v = document.querySelector(this.data.video)
    const el = this.el

    const showImage = ({
      detail
    }) => {
      if (name != detail.name) {
        return
      }
      v.play()
      object3D.position.copy(detail.position)
      object3D.quaternion.copy(detail.rotation)
      object3D.scale.set(detail.scale, detail.scale, detail.scale)
      object3D.visible = true
    }

    const hideImage = ({
      detail
    }) => {
      if (name != detail.name) {
        return
      }
      v.pause()
      object3D.visible = false
    }

    this.el.sceneEl.addEventListener('xrimagefound', showImage)
    this.el.sceneEl.addEventListener('xrimageupdated', showImage)
    this.el.sceneEl.addEventListener('xrimagelost', hideImage)
  }
})
<!doctype html>
<html>

<head>
  <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
  <meta name="apple-mobile-web-app-capable" content="yes">

  <title>8th Wall Alpha Video Example</title>

  <script src="//cdn.8thwall.com/web/aframe/8frame-0.9.0.min.js"></script>
  <script src="https://unpkg.com/aframe-chromakey-material/dist/aframe-chromakey-material.min.js"></script>


  <!-- XR Extras - provides utilities like load screen, almost there, and error handling.
                 See github.com/8thwall/web/xrextras -->
  <script src="//cdn.8thwall.com/web/xrextras/xrextras.js"></script>

  <!-- 8thWall Web - Replace the app key here with your own app key -->
  <script src="//apps.8thwall.com/xrweb?appKey=XXXXXXXXXX"></script>

</head>

<body>

  <a-scene xrweb="disableWorldTracking: true" xrextras-gesture-detector xrextras-almost-there xrextras-loading xrextras-runtime-error>

    <a-assets>
      <video id="alpha-video" autoplay playsinline crossorigin="anonymous" loop="true" src="https://cdn.glitch.com/087c366e-1fe1-4d07-8886-bfaf18fbc321%2Fdino.mp4?v=1588058174702">
              </video>
    </a-assets>

    <a-camera position="0 4 10" raycaster="objects: .cantap" cursor="fuse: false; rayOrigin: mouse;">
    </a-camera>

    <a-light type="directional" intensity="0.5" position="1 1 1"></a-light>

    <a-light type="ambient" intensity="1"></a-light>

    <!-- Note: "name:" must be set to the name of the image target uploaded to the 8th Wall Console -->
    <a-entity target-video="name: imageTargets; video: #alpha-video;" material="shader: chromakey; src: #alpha-video; color: 0.1 0.9 0.2" geometry="primitive: plane; height: 0.6; width: 1.38;">
    </a-entity>

  </a-scene>

  <script>
  </script>

</body>

</html>

任何人都可以帮我解决这个问题提前谢谢

4

2 回答 2

1

正如@Rob 已经说过的,这不是代码编写服务。但是这个可能对你有帮助https://www.8thwall.com/8thwall/image-api-aframe

于 2020-04-30T00:37:31.263 回答
0

请尝试这可能会帮助您进行多 AR 标记

<a-scene
  xrextras-almost-there
  xrextras-loading
  xrextras-runtime-error
  config-targets=
    "targets: macaw, owl, peacock, pelican, pigeon, puffin, cardinal, toucan, blue-jay, rooster"
  xrweb="disableWorldTracking: true">

于 2021-03-21T10:36:14.917 回答