Search Unity

Resolved ARFoundation - Number of Faces Currently Tracking Never Decreases

Discussion in 'AR' started by HidingGlass, Jul 29, 2020.

  1. HidingGlass

    HidingGlass

    Joined:
    Apr 29, 2015
    Posts:
    25
    I'm doing some face tracking and trying to determine the active number of faces being tracked so I can put up an overlay if no faces are in sight.

    Reading the docs, it seems like I'm supposed to be subscribing to the ARFaceManager.facesChanged event and keeping track of the added, removed, & updated faces.

    Faces get added and updated correctly, but there are never any faces in the 'removed' list and the faces never removed from the 'updated' list so the number of faces can only go up and never comes down.

    The ARFace is being destroyed so somewhere the subsystem is telling it the face is not tracking, but I can't find a way to get access to that myself.

    ARFoundation 3.1.3, Unity 2020.1, iPad Pro 4th Gen
     
    AdamBebko likes this.
  2. HidingGlass

    HidingGlass

    Joined:
    Apr 29, 2015
    Posts:
    25
    OK I found the solution. Just a different way of thinking (and looking farther up the chain of inheritance).

    So as far as ARFoundation is concerned, once it finds a face and looses it, the ARFace (which is an ARTrackable) is not 'removed' as an anchor because it still exists somewhere in the world. Instead its trackingState is set from 'tracking' to 'none'. You just need to loop through all of the faces in the updated list and check their trackingState.
     
    rocket5tim and AdamBebko like this.