Table of Contents

Class MotionTrackerFrameSource

Namespace
easyar
Assembly
EasyAR.Sense.dll

Controlseasyar.MotionTrackerCameraDevicein the scene, providing feature extensions within the Unity environment.

This frame source is a motion-tracking device that outputs motion data inARSession.

public class MotionTrackerFrameSource : FrameSource
Inheritance
MotionTrackerFrameSource
Inherited Members

Properties

Camera

Provided only when creating a new frame source. Accessed only duringAssemble().

On desktop devices or mobile phones, this camera represents theCamera in the virtual world corresponding to the real camera device in the physical environment. Its projection matrix and position will correspond to the real camera and are controlled by EasyAR. On head-mounted displays, this camera is only used to display diagnostic text in front of the eyes, not for rendering. The camera is not controlled by EasyAR.

protected override Camera Camera { get; }

CameraCandidate

An alternative toCamera, valid only when Unity XR Origin is not used. If not set, Camera.main will be used.

public Camera CameraCandidate { get; set; }

CameraFrameStarted

Provided only when creating a new frame source. It is accessed throughout the lifecycle of theARSession.

Whether camera frame input has started.

protected override bool CameraFrameStarted { get; }

DesiredFocusMode

Desired focus mode. Modifications are effective only before theDeviceOpened event or OnEnable.

Note: Due to hardware or system limitations, the focus switch may be ineffective on some devices.

public Optional<MotionTrackerCameraDeviceFocusMode> DesiredFocusMode { get; set; }

DesiredFrameRate

Desired device frame rate. Modifications are effective only before theDeviceOpened event or OnEnable.

public Optional<MotionTrackerCameraDeviceFPS> DesiredFrameRate { get; set; }

DesiredMinQualityLevel

Desired minimum allowed quality level. Modifications are effective only beforeAssemble().

public Optional<MotionTrackerCameraDeviceQualityLevel> DesiredMinQualityLevel { get; set; }

DesiredResolution

Desired resolution. Modifications are effective only before theDeviceOpened event or OnEnable.

If the image size is modified duringFrameRecorder recording, recording data will stop updating; recording needs to be restarted after closing.

public Optional<MotionTrackerCameraDeviceResolution> DesiredResolution { get; set; }

DesiredTrackingMode

Desired tracking mode. Modifications are effective only before the session starts.

public Optional<MotionTrackerCameraDeviceTrackingMode> DesiredTrackingMode { get; set; }

DeviceCameras

Provided only when creating a new frame source. Accessed only whenCameraFrameStarted is true.

Provides the device camera supplying camera frame data. If camera frame data is provided by multiple cameras, all cameras must be included in the list.

Ensure the value is correct whenCameraFrameStarted is true.

protected override List<FrameSourceCamera> DeviceCameras { get; }

DeviceQualityLevel

Gets the quality of Motion Tracking on the device. Combined with the application scenario, this value can determine whether to enable Motion Tracking.

public static MotionTrackerCameraDeviceQualityLevel DeviceQualityLevel { get; }

Display

Provided only when creating a new frame source. Accessed only duringAssemble().

Provides display system information. You can useDefaultSystemDisplay orDefaultHMDDisplay to get default display information.

protected override IDisplay Display { get; }

FrameRateRange

Frame rate range. Only available whenOpened is true.

public Vector2 FrameRateRange { get; }

IsAvailable

Provided only when creating a new frame source. Accessed only duringAssemble().

Whether the current frame source is available.

If the value equals null,CheckAvailability() will be called, and the value will be obtained after theCoroutine ends.

protected override Optional<bool> IsAvailable { get; }

IsCameraUnderControl

Provided only when creating a new frame source. Accessed only duringAssemble().

When true, the session updates the camera's transform and renders the camera image.

When creating head-mounted display extensions, it should be false. You should have full control over the 3D camera in the scene. You should handle camera rendering, especially in VST mode.

protected override bool IsCameraUnderControl { get; }

IsHMD

Provided only when creating a new frame source. Accessed only duringAssemble().

Whether the current frame source is a head-mounted display. If it is, diagnostic information will be displayed on a 3D board in front of the camera.

Some frame filters behave differently when running on devices.

protected override bool IsHMD { get; }

LocalPointCloud

Current point cloud data position information. Only available whenOpened is true.

public List<Vector3> LocalPointCloud { get; }

Opened

Whether the camera is open.

public bool Opened { get; }

Size

Current image size. Only available when bothOpened andMonoBehaviour.enabled are true.

public Vector2Int Size { get; }

enabled

Starts/stops video stream data acquisition whenARSession is running. Acquisition starts only after session startup and whenMonoBehaviour.enabled is true.

public bool enabled { get; set; }

Methods

Close()

Closes the device.

public void Close()

HitTestAgainstHorizontalPlane(Vector2)

Performs a Hit Test on horizontal planes detected in real-time within the current field of view. After tapping on a horizontal plane, returns the position coordinates of the 3D point closest to the Hit Test ray on that plane.pointInView needs to be normalized to [0, 1]^2.

public List<Vector3> HitTestAgainstHorizontalPlane(Vector2 pointInView)

Parameters

pointInView

HitTestAgainstPointCloud(Vector2)

Performs a Hit Test in the current point cloud, obtaining the position coordinates of the nearest 3D point along a ray from near to far from the camera.pointInView needs to be normalized to [0, 1]^2.

public List<Vector3> HitTestAgainstPointCloud(Vector2 pointInView)

Parameters

pointInView

OnSessionStart(ARSession)

Provided only when creating a new frame source. Accessed only duringStartSession().

Handles session startup if this frame source has been assembled intoAssembly. This method is designed for deferred initialization; you can perform AR-specific initialization work here.

protected override void OnSessionStart(ARSession session)

Parameters

session

OnSessionStop()

Provided only when creating a new frame source. Accessed duringStopSession(bool) or other session stop/corruption processes.

Handles session stopping if this frame source has been assembled intoAssembly. You can use this method to destroy resources created duringStartSession() and session runtime and restore internal state. This method is guaranteed to be called before the session is destroyed. If the frame source is destroyed before the session, this method will not be called, and the session will be corrupted.

protected override void OnSessionStop()

Open()

Opens the device. IfOpen() andClose() are not called manually,ARSession will automaticallyOpen() after startup.

public void Open()

Events

DeviceClosed

Event for device closing.

public event Action DeviceClosed

DeviceOpened

Event for device opening, the bool value indicates success.

public event Action<bool, PermissionStatus, string> DeviceOpened