ARCore – Anchors 附加到 Trackable 时的作用是什么?

ARCore – What is the role of Anchors when they are attached to Trackable?

我有一个示例 ARCore 代码,我在其中将锚点附加到我检测到的每个新的可跟踪对象。我不明白附加这些锚点的效用以及将多个锚点附加到单个 Trackable 的需要是什么。

我已经查看了文档。我找不到太多解释。

Collection<AugmentedImage> updatedAugmentedImages =
    frame.getUpdatedTrackables(AugmentedImage.class);

// Iterate to update augmentedImageMap, remove elements we cannot draw.
for (AugmentedImage augmentedImage : updatedAugmentedImages) {
  switch (augmentedImage.getTrackingState()) {
    case PAUSED:
      // When an image is in PAUSED state, but the camera is not PAUSED, it has been detected,
      // but not yet tracked.
      String text = String.format("Detected Image %d", augmentedImage.getIndex());
      messageSnackbarHelper.showMessage(this, text);
      break;

    case TRACKING:
      // Have to switch to UI Thread to update View.
      this.runOnUiThread(
          new Runnable() {
            @Override
            public void run() {
              fitToScanView.setVisibility(View.GONE);
            }
          });

      // Create a new anchor for newly found images.
      if (!augmentedImageMap.containsKey(augmentedImage.getIndex())) {
        Anchor centerPoseAnchor = augmentedImage.createAnchor(augmentedImage.getCenterPose());
        augmentedImageMap.put(
            augmentedImage.getIndex(), Pair.create(augmentedImage, centerPoseAnchor));
      }

... 嗨 Parul,

Anchors 用增强世界映射现实世界,让你在特定位置看到模型。事实上,锚点是虚拟内容和传感器获取的内容之间的接触点。

我会尝试更好地解释这个概念:

当您将 3d 模型放置在某处时,您需要根据原点定义模型的位置 (x,y,z) 和方向。你知道起源在哪里,因为你在隐含地创造这个世界。 每次你移动你的 phone 并且 ArCore 是 运行 时,phone 会使用传感器(例如相机、陀螺仪、加速度计......)存储一些关于你的运动的信息,创建一个内存您周围 space 的表示(通常是稀疏点云)。

我怎么能说我的虚拟世界中的一个点与 phone 生成的这个新 space 中存在的点相同?我用锚

在您的示例中,此点是计算机视觉算法检测到的参考图像的点。在其上放置锚点假设您放置增强内容的虚拟世界具有对该真实点的引用,并且当您移动 phone.

时该内容出现在正确的位置

ArCore 将根据您的动作在每一帧更新锚点,让内容根据现实世界更加逼真。

what is the need of attaching multiple anchors to a single trackable.

通常你攻击多个锚点到一个trackable以获得更多的参考点并让ArCore减少虚拟世界位置和space之间的误差。

不必为每个对象都创建一个新的锚点。对具有某种空间关系的模型使用相同的锚点是一个很好的提示,同时假设这些对象距离不太远。 还请记住,使用和创建锚点在您 phone 使用的资源方面有成本。这可能会导致您的应用程序性能下降,从而破坏用户体验。

希望对您有所帮助。

干杯。

您还可以参考这篇文章:

https://developers.google.com/ar/develop/developer-guides/anchors

如果您想了解更多关于这些技术背后的过程,请务必查看 Visual Inertial Odometry and SLAM。只是 google 了解更多。

In ARCore there are two simple concepts about Trackable and Anchor:

  • Trackable 是 ARCore 可以跟踪的东西,Anchors 可以附加到。

  • Anchor 是可以在 space.

  • 中为您保存 3D 几何体的东西

ArAnchor 是一个空对象,当 ArSession 的跟踪是 ON 时,它可以在世界坐标中容纳一个 Renderable 对象。将 ArAnchor 想象成 3D 对象的本地轴。每个 3D 对象都有一个枢轴点,对吧?所以,这个枢轴点必须满足一个ArAnchor。

Any 3D geometry (aka Renderable) must be attached to its own ArAnchor. But one ArAnchor can hold several 3D objects.

阅读 Working with anchors 了解更多详情。

希望对您有所帮助。