unity3d - 启用自动对焦会导致我的 AR 场景出现跟踪问题吗?
问题描述
我正在使用 AR Core 和 Unity 2018.2.20f 在 Galaxy S7 上构建 AR 场景,我使用 AugmentedImageVisualizer 跟踪图像并将 3d 游戏对象放在前面。为了跟踪图像,我需要启用自动对焦。问题是我的锚四处抖动,有时完全移开并消失。从调试来看,似乎是相机自动对焦可能导致了跟踪问题。
到目前为止,我最好的解决方法是在检测到图像后将相机配置切换为固定,但有 1/3 的时间锚点在切换到固定焦点时移动。如果一旦相机处于固定焦点,锚点仍然在视线内,则跟踪效果很好。
以前有没有其他人注意到这个问题?有没有办法更具体地控制相机对焦?
解决方案
如果您使用 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
}
}
}
推荐阅读
- python - Sympy,矩阵,特征值,哦,我的……特征值错误
- swift - WKWebview:如何防止 Laravel 页面链接在 safari 中打开?
- ios - 为什么我的 CGPoint 返回其他字符?
- python - 如何在 tweepy 的一条推文中搜索多个单词?
- windows - 如何在 Visual Studio 2019 社区版中打开新的 MonoGame 桌面项目?
- string - 使用 malloced 字符串创建 Rust 字符串是否安全?
- javascript - 切换 Bootstrap 4 桌面导航的滑入式动画
- java - 如何创建具有多个端点的heroku服务器以进行方形支付?
- javascript - 修改从已呈现可见空白的网页复制文本的方式
- jquery - 提交时如何使用 jQuery keydown 选择两个提交按钮之一?