Resetting the target tracker

Has anyone figured out a way to reset the target tracker? I find that if you lose sight of the marker image it will occasionally not recognize it anymore. I’ve searched the patches and API and there doesn’t seem to be any way to do this. Have you encountered this and do you have any solutions? When this happens it is possible to reset it by taking an image but that’s pretty quirky and hard to communicate to the user.

2 Likes

I haven’t done much with the target tracker, but I would think you could force it to reset by changing the tracking mode. Here’s what I see in Scene.TrackingMode:

{"VERTICAL_PLANE":"VERTICAL_PLANE","MOVING_OBJECT":"MOVING_OBJECT","ARBITRARY_DEPTH":"ARBITRARY_DEPTH","PLANE":"PLANE"}

But… for some reason this fixed target tracker is telling me it’s a plane tracker. I thought it would be vertical plane…

Here’s a script for debugging. The confidence value could be used to display some kind of meter to get the idea across to the user

const Scene = require('Scene')
const {log, watch} = require('Diagnostics')

log(Scene.TrackingMode) // {"VERTICAL_PLANE":"VERTICAL_PLANE","MOVING_OBJECT":"MOVING_OBJECT","ARBITRARY_DEPTH":"ARBITRARY_DEPTH","PLANE":"PLANE"}

Scene.root.findFirst('fixedTargetTracker0').then(ftt => {
  watch('mode', ftt.mode)
  watch('confidence', ftt.confidence)
})

And here’s what I got from logging the fixed target tracker. Seems mostly related to the plane tracker, but I’m not sure all of the methods will work on it (e.g. hitTest, trackPoint).


PlaneTracker {
  """
    The `PlaneTracker` class provides functionality for locating a 3D plane based on 2D screen coordinates.
  """
  Properties:
    confidence: Object
    """
      ```
      (get) confidence: StringSignal
      (set) (Not Available)
      ```

      Returns tracking confidence level info.
      This value indicates if PlaneTracker is currently tracking and how confident it is in reported results.
      Possible values:
      - HIGH
      - MEDIUM
      - LOW
      - NOT_TRACKING
    """
    mode: Object
    """
      ```
      (get) mode: Signal<SceneModule.TrackingMode>
      (set) mode: Signal<SceneModule.TrackingMode>
      ```

      Specifies if this tracker object should track horizontal plane or moving object.
      **Note:** on invalid value provided in setter, the mode will default to `SceneModule.TrackingMode.PLANE`.

      **See Also**: `PlaneTracker.setMode`.
    """
  Methods:
    performHitTest
    """
      ```
      performHitTest(screenXLocation: number, screenYLocation: number): Promise<Point3D>
      performHitTest(screenLocation: Point2D): Promise<Point3D>
      ```

      Returns a promise that is resolved with a point on tracked plane in local coordinates of PlaneTracker (in 3D units)
      or null if plane is not found at given screen location.
    """
    setMode
    """
      ```
      setMode(mode: Signal<SceneModule.TrackingMode>, config?: {fallback: SceneModule.TrackingMode}): void
      ```

      Specifies if this tracker object should track horizontal plane or moving object.
      **Note:** on invalid value provided in setter, the mode will default to `fallback` (or `SceneModule.TrackingMode.PLANE` if fallback is not specified).

      **See Also**: `PlaneTracker.mode`.
    """
    trackPoint
    """
      ```
      trackPoint(screenLocation: Point2D): void
      trackPoint(screenX: number, screenY: number): void
      trackPoint(screenLocation: Point2DSignal, gestureState: StringSignal): void
      ```

      PlaneTracker origin is bound to a point in 3d space, located on detected plane.
      This method updates PlaneTracker to track 3d point currently under given screen coordiantes.
      This also triggers new plane detection, in result this object's transform will be modified.
      Version with signal parameters can be used in touch gestures for continuous updating:
      ```
      TouchGestures.onPan().subscribe(function(gesture) {
        planeTracker.trackPoint(gesture.location, gesture.state);
      });
      ```
    """
}

FWIW I know there has been some weird bugs with the target tracker lately.

I had the same problem lately. I think there is a bug.

Thanks Josh! I wasn’t trying it with render passes but I do have some projects with render passes so I will watch for that. The issue happens even with simple examples like the default poster. Either it won’t trigger the second time or more often it just seems to show up with some random offset that isn’t correct. I will look into changing the tracking mode which is a good lead. I’m wondering whether you can do that when using a specific type of tracker though.

I’ll give this a shot but I might be back for some coding tips if I get stuck. Thanks again!