ARTrackedImage trackedImagesChanged value updated error

 private void OnARTrackedImagesChanged(ARTrackedImagesChangedEventArgs args)
        {
            if (args.added != null)
            {
                foreach (var track in args.added)
                {
                    if (track.trackingState == TrackingState.Tracking)
                    {  
                        //Debug.LogFormat("DmQrMark.TrackedImagesChanged.Add==> name:{0}", track.trackableId);
                        cbTracking?.Invoke(track);
                        return;
                    }
                }
            }
            if (args.updated != null)
            {
                foreach (var track in args.updated)
                {
                    if (track.trackingState == TrackingState.Tracking)
                    {
                        //Debug.LogFormat("DmQrMark.TrackedImagesChanged.Update==> name:{0}", track.trackableId);
                        cbTracking?.Invoke(track);
                        return;
                    }
                }
            }
        }

I followed the official example for image recognition and use the add and update methods to get the currently captured object. However, I’m experiencing an issue with the update information being incorrect during image recognition.

After recognizing an image, I want to scan a different picture. Even when I move the first picture out of the camera’s view, it still appears in the update. Is there a way to clear the recognized images so I can reuse the add method? I noticed that the content returned by add is always correct.

Has anyone encountered similar problems or have any suggestions? Any help is appreciated :slightly_smiling_face:

2 Likes

I collected some knowledge while developing Business Card — my Asset with Multiple Image Tracking.

ARCore (Android) Behavior

ARCore Requirements: Supported Devices & Augmented Images.

ARCore API assumes that AR Images are static in the environment (2), so once they are recognized successfully, they will always appear in the list of anchors (updated list) (1) until the session is reset.

This means 2 things:

  1. AR Foundation will never mark the Tracked Image as removed, and it will never mark the Tracking State for the Tracked Image as None.
  2. If you try to test 2 Different Images via your monitor (desktop/laptop) and you will switch images with CMD+Tab (macOS) or Alt+Tab (Windows), so Images will be in the same position on the monitor, then ARCore will not understand that.

ARKit (iOS) Behavior

You can learn more about ARKit Requirements for Image Tracking here.

  1. Tracking State for the Tracked Image can be set as None when the camera stops seeing it.
  2. 2 images can be successfully tested on the monitor in the same position, as it described above for ARCore.

Read my Full Article about AR Testing here.

The only way to do this is to reset the entire AR Session, which is not recommended. A better way to do this for example is to use MonoBehaviour.OnBecameVisible if you are trying to detect when a GameObject in your scene has become visible again. Unity - Scripting API: MonoBehaviour.OnBecameVisible()

ARCore and ARKit intentionally update image tracking even if the image is out of frame.

1 Like

Why? It works like a charm in my project.

Resetting the session is fine to do, it just takes a couple seconds and isn’t necessary.

1 Like