首页 > 解决方案 > 启用自动对焦会导致我的 AR 场景出现跟踪问题吗?

问题描述

我正在使用 AR Core 和 Unity 2018.2.20f 在 Galaxy S7 上构建 AR 场景,我使用 AugmentedImageVisualizer 跟踪图像并将 3d 游戏对象放在前面。为了跟踪图像,我需要启用自动对焦。问题是我的锚四处抖动,有时完全移开并消失。从调试来看,似乎是相机自动对焦可能导致了跟踪问题。

到目前为止,我最好的解决方法是在检测到图像后将相机配置切换为固定,但有 1/3 的时间锚点在切换到固定焦点时移动。如果一旦相机处于固定焦点,锚点仍然在视线内,则跟踪效果很好。

以前有没有其他人注意到这个问题?有没有办法更具体地控制相机对焦?

标签: unity3daugmented-realityarcore

解决方案


如果您使用 ARCore 1.9 或更高版本,则增强图像的跟踪比以前的版本有所改进。请从下面的链接中找到官方版本。

链接: https ://github.com/google-ar/arcore-unity-sdk/releases

就调试而言,将配置设置为自动模式就可以了。有时,如果您在配置中同时使用平面跟踪和增强图像,可能会出现抖动。

此外,无需使用增强可视化器来检测增强图像。以下代码可以帮助跟踪增强图像并放置任何 3D 对象。

using GoogleARCore;

private List<AugmentedImage> augmentedImages = new List<AugmentedImage>();

public GameObject AndyObject;//object to place on the image

private bool Is_Placed=false;

void Update()
{
  Session.GetTrackables<AugmentedImage>(augmentedImages, 
                          TrackableQueryFilter.Updated);
  foreach (var image in augmentedImages)
  {
    if (image.TrackingState == TrackingState.Tracking &&     Is_Placed==false)
    {
       Anchor anchor=image.CreateAnchor(image.CenterPose);
       var andyref = Instantiate(AndyObject,image.CenterPose.position,
                                     image.CenterPose.rotation);
       andyref.transform.parent=anchor.transform;
       Is_Placed=true;//To only place the object once
     }
   }
}

推荐阅读