0

I am implementing the new augmenting images recognition feature of the ArCore. The recognition of my database images is working fine and a video start playing when they get recognized. However i was wondering if there is any listener that is called when the image is not visible any more in the scene so that i can stop and hide the video of that image. Currently in my implementation the video stays to the same position in the scene where the image was recognized even if i remove the physical image.

makis.k
  • 432
  • 6
  • 23

2 Answers2

2

Check the current TrackingMethod for the AugmentedImage when the TrackingState is Tracking. When the image is in view of the camera the TrackingMethod is FULL_TRACKING ,else it will be in LAST_KNOWN_POSE. If you are using the sample augmentedImages example, it will be like this in AugmentedImageActvity.java -

 private void onUpdateFrame(FrameTime frameTime) 
 {
 .
   for (AugmentedImage augmentedImage : updatedAugmentedImages) 
   {
   .
     switch (augmentedImage.getTrackingState())
     {
     .
       case TRACKING: if(augmentedImage.getTrackingMethod()==AugmentedImage.TrackingMethod.FULL_TRACKING) {
                        //Enable VideoNode 
                      }
                      else{
                        //Disable VideoNode / Pause MediaPlayer /detach node
                      }
      }
    }
  }
kewal kishan
  • 116
  • 1
  • 15
1

You can use public TrackingState getTrackingState () if it returns public static final TrackingState STOPPED you can stop your video or destroy however you want. For more details you can refer here

Ali Kanat
  • 1,888
  • 3
  • 13
  • 23
  • I thought of that in the beginning as well but the tracking state of the image is still `TRACKING` even if i remove the image from the scene, so `STOPPED` is not called as i would expect it to do. – makis.k Nov 18 '18 at 18:28
  • Have you checked [AugmentedImage](https://github.com/google-ar/sceneform-android-sdk/blob/master/samples/augmentedimage/app/src/main/java/com/google/ar/sceneform/samples/augmentedimage/AugmentedImageActivity.java) sample. This should work exactly like you wanted. – Ali Kanat Nov 18 '18 at 21:29
  • My code is based on that but as i mentioned the tracking state is not working as expecting – makis.k Nov 19 '18 at 10:23
  • Can you share your code where you check for tracking so i can try to reproduce the error? – Ali Kanat Nov 19 '18 at 10:44