两者都返回目前已知的所有可跟踪对象吗?
为什么我们需要两者?
什么时候应该调用哪个?
Session.getAllAnchors
和 Frame.getUpdatedAnchors
也是同样的问题。
最佳答案
全局 Session.getAllTrackables
返回所有已知可跟踪对象的列表。如果启用平面检测,此列表包括 Planes
,以及作为调用 hitTest(float, float)
的副作用创建的 Points
或 createAnchor(Pose)
。
例子:
planeRenderer.drawPlanes(session.getAllTrackables(Plane.class),
camera.getDisplayOrientedPose(),
projmtx);
正如您在此处看到的,planeRenderer
类用于绘制平面。它使用 .drawPlanes()
方法来渲染 ARCore session 使用 View 和投影矩阵识别的任何已识别平面。它通过调用 getAllTrackables(Plane.class)
传递所有平面。
但本地 Frame.getUpdatedTrackables
返回由 update()
更改的特定类型的 trackables> 返回此 Frame
。要检索所有已更改的可跟踪对象,filterType 可以是 Trackable.class
或 Point.class
或 Plane。类
。每当更新屏幕框架时都会触发此方法。
例子:
private void onUpdateFrame(FrameTime frameTime) {
Frame frame = arSceneView.getArFrame();
Collection updatedAugmentedImages = frame.getUpdatedTrackables(AugmentedImage.class);
}
关于 update()
的几句话:
public Frame update()
Updates the state of the ARCore system. This includes: receiving a new camera frame, updating the location of the device, updating the location of tracking anchors, updating detected planes, etc. This call may cause off-screen OpenGL activity. Because of this, to avoid unnecessary frame buffer flushes and reloads, this call should not be made in the middle of rendering a frame or offscreen buffer. This call may update the pose of all created anchors and detected planes. The set of updated objects is accessible through
getUpdatedTrackables(Class)
.
关于java - Session.getAllTrackables 和 Frame.getUpdatedTrackables 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49241526/