SurfaceTracking

Demonstrate how to use surface tracking.

How to Use

../../_images/image_45.png
Mark 1: Display system status and operation hint.
Mark 2: Switch world center mode.
Mark 3: Start/Stop tracking.

Move the cube on the surface with on finger. Two finger pinch will scale the cube and two finger horizontal move will rotate the cube.

How It Works

Objects under world root

WorldRoot is designed to do these things,

  • Control show/hide of objects when tracking status change.

  • Move together against camera according to ARSession.CenterMode.

You can ignore WorldRoot If you can make sure all above is handled by yourself.

In this sample, WorldRootController.ActiveControl is set to ActiveControlStrategy.HideWhenNotTracking, so the cube will hide when tracking fails.

../../_images/image_s11_1.png

Tracking on/off

Surface tracking can be turned on or off using SurfaceTrackerFrameFilter.enabled. You can turn the tracking off when it is not used to save performance, it will not turn off the camera or any other tracking features.

../../_images/image_s11_2.png ../../_images/image_s11_3.png

Move object on surface

You can put object in one location where SurfaceTracker will track continuously. Put objects in other location may look like the objects are not tracked.

When you want to move object to other parts of the surface, you can change the location SurfaceTracker tracks using SurfaceTracker.alignTargetToCameraImagePoint. In this way, you will see objects move on the surface. But the camera will not move in a continuous way because surface tracking do not keep real world scale, so object size outside the surface node may not be stable.

SurfaceTracker is not designed to be a VIO system, so in case you find the object or the camera behaves strange, you may take a look at MotionTracking sample which behaves like ARCore and ARKit.

var viewPoint = new Vector2(touch.position.x / Screen.width, touch.position.y / Screen.height);
if (tracker && tracker.Tracker != null && Session.FrameCameraParameters.OnSome)
{
    var coord = EasyARController.Instance.Display.ImageCoordinatesFromScreenCoordinates(viewPoint, Session.FrameCameraParameters.Value, Session.Assembly.Camera);
    tracker.Tracker.alignTargetToCameraImagePoint(coord.ToEasyARVector());
}

Center mode

Two mode of ARSession.CenterMode are valid in world sensing.

In ARSession.ARCenterMode.WorldRoot the camera will move automatically when the device moves, and the WorldRoot stay. In ARSession.ARCenterMode.Camera, the camera do not automatically move when the device moves. It is suggested to use ARSession.ARCenterMode.WorldRoot in most cases.