Search Unity

[ARFoundation3] AR Tracked Image Manager not working as expected...

Discussion in 'Handheld AR' started by Aaron-Meyers, Nov 15, 2019.

  1. Aaron-Meyers


    Dec 8, 2009
    I've got my image tracking properly, but it never seems to get removed. My setup is simple, just one tracked image. Here is the function I use to handle the trackedImagesChanged event:
    Code (CSharp):
    1. private void OnTrackedImagesChanged( ARTrackedImagesChangedEventArgs eventArgs )
    2. {
    3.     if ( eventArgs.added.Count > 0 )
    4.     {
    5.         var tracked = eventArgs.added[0];
    6.         _startBeacon.SetActive( true );
    7.         _startBeacon.transform.position = tracked.transform.position;
    8.         _startBeacon.transform.rotation = tracked.transform.rotation;
    9.         Logger.Add( "Touch the green beacon!" );
    10.     }
    12.     if ( eventArgs.updated.Count > 0 )
    13.     {
    14.         var tracked = eventArgs.updated[0];
    15.         _startBeacon.transform.position = tracked.transform.position;
    16.         _startBeacon.transform.rotation = tracked.transform.rotation;
    17.     }
    19.     if ( eventArgs.removed.Count > 0 )
    20.     {
    21.         _startBeacon.SetActive( false );
    22.         Logger.Add( "Tracked image lost!" );
    23.     }
    24. }
    The "added" if statement runs once when it first detects the tracked image, but if I remove the image from view, the "removed" if statement is never triggered.

    Am I misunderstanding how this event is meant to be used? Anyone else have this issue?
  2. Aaron-Meyers


    Dec 8, 2009
    Ok... I was going to report a bug on the GitHub repo for ARFoundation samples, but I discovered that there are already two different threads (one & two) discussing the issue, which is present an ARFoundation 2 and 3, going back months ago and it remains unresolved.

    It seems to me that the life cycle of an ARTrackedImage is fundamentally broken since it never appears in the "removed" list when the image is no longer tracked and it never reappears in the "added" list when tracking resumes.

    Others in the threads I've linked report that the ARTrackedImage's tracking state never reports TrackingState.None.

    @tdmowrer can you weigh in on this? Will this bug be addressed?
  3. ibrahimpenekli


    Mar 10, 2015
    I think it is appeared in removed list if only if you manually remove the image anchor from the AR tracking pipeline. Maybe you should set timer when camera is facing image's last location and the tracking state is None. Remove image anchor manually when your elapsed time expired.