Table of Contents

Class MotionTrackerFrameSource

Namespace
easyar
Assembly
EasyAR.Sense.dll

Controls the easyar.MotionTrackerCameraDevice in the scene, providing functional extensions within the Unity environment.

This frame source is a motion-tracking device that outputs motion data in the ARSession.

public class MotionTrackerFrameSource : FrameSource
Inheritance
MotionTrackerFrameSource
Inherited Members

Properties

Camera

Provided only when creating a new frame source. Accessed only during the Assemble() process.

On desktop devices or phones, this camera represents the Camera corresponding to the physical camera device in the virtual world. 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 also not controlled by EasyAR.

protected override Camera Camera { get; }

Property Value

CameraCandidate

Alternative to Camera, only valid when not using Unity XR Origin. If not set, Camera.main will be used.

public Camera CameraCandidate { get; set; }

Property Value

CameraFrameStarted

Provided only when creating a new frame source. Accessed throughout the lifecycle of ARSession.

Whether camera frame input has started.

protected override bool CameraFrameStarted { get; }

Property Value

DesiredFocusMode

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

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

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

Property Value

DesiredFrameRate

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

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

Property Value

DesiredMinQualityLevel

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

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

Property Value

DesiredResolution

Desired resolution. Modifications are only effective before the DeviceOpened event or OnEnable.

If the image size is modified during FrameRecorder recording, recording data will stop updating; close and restart recording is required.

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

Property Value

DesiredTrackingMode

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

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

Property Value

DeviceCameras

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

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

Ensure the value is correct when CameraFrameStarted is true.

protected override List<FrameSourceCamera> DeviceCameras { get; }

Property Value

DeviceQualityLevel

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

public static MotionTrackerCameraDeviceQualityLevel DeviceQualityLevel { get; }

Property Value

Display

Provided only when creating a new frame source. Accessed only during the Assemble() process.

Provides display system information. You can use DefaultSystemDisplay or DefaultHMDDisplay to obtain default display information.

protected override IDisplay Display { get; }

Property Value

FrameRateRange

Frame rate range. Only available when Opened is true.

public Vector2 FrameRateRange { get; }

Property Value

IsAvailable

Provided only when creating a new frame source. Accessed only during the Assemble() process.

Whether the current frame source is available.

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

protected override Optional<bool> IsAvailable { get; }

Property Value

IsCameraUnderControl

Provided only when creating a new frame source. Accessed only during the Assemble() process.

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; }

Property Value

IsHMD

Provided only when creating a new frame source. Accessed only during the Assemble() process.

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 may operate differently on the device.

protected override bool IsHMD { get; }

Property Value

LocalPointCloud

Current point cloud data location information. Only available when Opened is true.

public List<Vector3> LocalPointCloud { get; }

Property Value

Opened

Whether the camera is open.

public bool Opened { get; }

Property Value

Size

Current image size. Only available when both Opened and MonoBehaviour.enabled are true.

public Vector2Int Size { get; }

Property Value

Methods

Close()

Closes the device.

public void Close()

HitTestAgainstHorizontalPlane(Vector2)

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

public List<Vector3> HitTestAgainstHorizontalPlane(Vector2 pointInView)

Parameters

pointInView

Returns

HitTestAgainstPointCloud(Vector2)

Performs a Hit Test in the current point cloud, obtaining the position coordinates of the nearest 3D point on 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

Returns

OnSessionStart(ARSession)

Provided only when creating a new frame source. Accessed only during the StartSession() process.

Handles session startup if this frame source has been assembled into Assembly. This method is designed for delayed 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 during StopSession(bool) or other session stop/corruption processes.

Handles session stopping if this frame source has been assembled into Assembly. You can use this method to destroy resources created in StartSession() and during session operation, and restore internal state. This method is guaranteed to be called before session destruction. If the frame source is destroyed before the session, it will not be called, and the session will be corrupted.

protected override void OnSessionStop()

Open()

Opens the device. If Open() and Close() are not manually called, ARSession will automatically Open() upon startup.

public void Open()

Events

DeviceClosed

Device closed event.

public event Action DeviceClosed

Event Type

DeviceOpened

Device opened event, the bool value indicates success or failure.

public event Action<bool, PermissionStatus, string> DeviceOpened

Event Type