Do both return all trackables known for now?
Why do we need both?
When should call which one?
Same question is for Session.getAllAnchors and Frame.getUpdatedAnchors.
Global Session.getAllTrackables returns the list of all known trackables. If plane detection is enabled this list includes Planes, as well as Points created as a side-effect of calls to hitTest(float, float) or createAnchor(Pose).
Example:
planeRenderer.drawPlanes(session.getAllTrackables(Plane.class),
camera.getDisplayOrientedPose(),
projmtx);
As you can see here planeRenderer class is for drawing planes. It uses a .drawPlanes() method to render any of the identified planes the ARCore session has identified using the view and projection matrices. It passes all the planes in thru a call to getAllTrackables(Plane.class).
But local Frame.getUpdatedTrackables returns the trackables of a particular type that were changed by the update() that returned this Frame. To retrieve all changed trackables a filterType may be Trackable.class or Point.class or Plane.class. This method gets fired whenever screen frame is updated.
Example:
private void onUpdateFrame(FrameTime frameTime) {
Frame frame = arSceneView.getArFrame();
Collection updatedAugmentedImages = frame.getUpdatedTrackables(AugmentedImage.class);
}
And a couple of words about 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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With