Sceneform-android-sdk: Sceneform + Augmented Images?

Created on 9 May 2018  路  3Comments  路  Source: google-ar/sceneform-android-sdk

Since sceneform handles the render loop, I don't see a way to do what the Augmented Images documentation suggests: getting the updated trackables from a Frame. Is there an alternative method that sceneform exposes to hook into the render loop and run getUpdatedTrackables(AugmentedImage.class)?

question

Most helpful comment

The ArSceneView updates the ARCore Frame object before drawing the scene. You can access the frame by calling getArFrame() from a method registered with setOnUpdateListener() which is called once per frame.

    arSceneView
        .getScene()
        .setOnUpdateListener(
            frameTime -> {
              Frame frame = arSceneView.getArFrame();
              if (frame == null) {
                return;
              }

              Collection<AugmentedImage> augmentedImages = frame
                  .getUpdatedTrackables(AugmentedImage.class);
            });

Alternatively, you can subclass Node, override onUpdate, and access the ARCore frame from there.

All 3 comments

The ArSceneView updates the ARCore Frame object before drawing the scene. You can access the frame by calling getArFrame() from a method registered with setOnUpdateListener() which is called once per frame.

    arSceneView
        .getScene()
        .setOnUpdateListener(
            frameTime -> {
              Frame frame = arSceneView.getArFrame();
              if (frame == null) {
                return;
              }

              Collection<AugmentedImage> augmentedImages = frame
                  .getUpdatedTrackables(AugmentedImage.class);
            });

Alternatively, you can subclass Node, override onUpdate, and access the ARCore frame from there.

In what point of the ArFragment lifecycle will arSceneView.getSession() not return null, so that I can run AugmentedImageDatabase.deserialize(session, inputStream) ?

The session becomes available when ArFragment is resumed. However, you must still check to see if it is null. It may not be available right away if camera permission still needs to be granted or ARCore needs to be installed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dementia2029 picture dementia2029  路  3Comments

hcjung2000 picture hcjung2000  路  3Comments

kunal-wayfair picture kunal-wayfair  路  3Comments

chiaolinghong3d picture chiaolinghong3d  路  3Comments

tigran-babajanyan picture tigran-babajanyan  路  3Comments