samples/augmentedimage/app/src/main/java/com/google/ar/sceneform/samples/augmentedimage/AugmentedImageActivity.java
private void onUpdateFrame(FrameTime frameTime) {
    Frame frame = arFragment.getArSceneView().getArFrame();

    // If there is no frame or ARCore is not tracking yet, just return.
    if (frame == null || frame.getCamera().getTrackingState() != TrackingState.TRACKING) {
      return;
    }

    Collection<AugmentedImage> updatedAugmentedImages =
        frame.getUpdatedTrackables(AugmentedImage.class);
    for (AugmentedImage augmentedImage : updatedAugmentedImages) {
      switch (augmentedImage.getTrackingState()) {
        case PAUSED:
          // When an image is in PAUSED state, but the camera is not PAUSED, it has been detected,
          // but not yet tracked.
          String text = "Detected Image " + augmentedImage.getIndex();
          SnackbarHelper.getInstance().showMessage(this, text);
          break;

        case TRACKING:
          // Have to switch to UI Thread to update View.
          fitToScanView.setVisibility(View.GONE);

          // Create a new anchor for newly found images.
          if (!augmentedImageMap.containsKey(augmentedImage)) {
            AugmentedImageNode node = new AugmentedImageNode(this);
            node.setImage(augmentedImage);
            augmentedImageMap.put(augmentedImage, node);
            arFragment.getArSceneView().getScene().addChild(node);
          }
          break;

        case STOPPED:
          augmentedImageMap.remove(augmentedImage);
          break;
      }
    }
  }
/**
   * Registered with the Sceneform Scene object, this method is called at the start of each frame.
   *
   * @param frameTime - time since last frame.
   */
Registered with the Sceneform Scene object, this method is called at the start of each frame.
@param frameTime - time since last frame.
Registered with the Sceneform Scene object this method is called at the start of each frame . @param frameTime - time since last frame .
private void onUpdateFrame(FrameTime frameTime) {
    Frame frame = arFragment.getArSceneView().getArFrame();
    if (frame == null || frame.getCamera().getTrackingState() != TrackingState.TRACKING) {
      return;
    }
    Collection<AugmentedImage> updatedAugmentedImages =
        frame.getUpdatedTrackables(AugmentedImage.class);
    for (AugmentedImage augmentedImage : updatedAugmentedImages) {
      switch (augmentedImage.getTrackingState()) {
        case PAUSED:
          String text = "Detected Image " + augmentedImage.getIndex();
          SnackbarHelper.getInstance().showMessage(this, text);
          break;
        case TRACKING:
          fitToScanView.setVisibility(View.GONE);
          if (!augmentedImageMap.containsKey(augmentedImage)) {
            AugmentedImageNode node = new AugmentedImageNode(this);
            node.setImage(augmentedImage);
            augmentedImageMap.put(augmentedImage, node);
            arFragment.getArSceneView().getScene().addChild(node);
          }
          break;
        case STOPPED:
          augmentedImageMap.remove(augmentedImage);
          break;
      }
    }
  }
private void onUpdateFrame ( FrameTime frameTime ) { Frame frame = arFragment . getArSceneView ( ) . getArFrame ( ) ; if ( frame == null || frame . getCamera ( ) . getTrackingState ( ) != TrackingState . TRACKING ) { return ; } Collection < AugmentedImage > updatedAugmentedImages = frame . getUpdatedTrackables ( AugmentedImage . class ) ; for ( AugmentedImage augmentedImage : updatedAugmentedImages ) { switch ( augmentedImage . getTrackingState ( ) ) { case PAUSED : String text = "Detected Image " + augmentedImage . getIndex ( ) ; SnackbarHelper . getInstance ( ) . showMessage ( this , text ) ; break ; case TRACKING : fitToScanView . setVisibility ( View . GONE ) ; if ( ! augmentedImageMap . containsKey ( augmentedImage ) ) { AugmentedImageNode node = new AugmentedImageNode ( this ) ; node . setImage ( augmentedImage ) ; augmentedImageMap . put ( augmentedImage , node ) ; arFragment . getArSceneView ( ) . getScene ( ) . addChild ( node ) ; } break ; case STOPPED : augmentedImageMap . remove ( augmentedImage ) ; break ; } } }
Registered with the Sceneform Scene object, this method is called at the start of each frame.
Registered with the Sceneform Scene object this method is called at the start of each frame .
// If there is no frame or ARCore is not tracking yet, just return. // When an image is in PAUSED state, but the camera is not PAUSED, it has been detected, // but not yet tracked. // Have to switch to UI Thread to update View. // Create a new anchor for newly found images.