Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between Session.getAllTrackables and Frame.getUpdatedTrackables?

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.

like image 425
redpearl Avatar asked Mar 12 '18 17:03

redpearl


1 Answers

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).

like image 170
Andy Jazz Avatar answered Oct 15 '22 06:10

Andy Jazz