ARFoundationFrameSource Class

Description

A custom frame source which connects AR Foundation output to EasyAR input in the scene, providing AR Foundation support using custom camera feature of EasyAR Sense.

This frame source is one type of motion tracking device, and will output motion data in a ARSession .

AR Foundation is required to use this frame source, you need to setup AR Foundation according to official documents.

This frame source will use ARFoundation.ARSession.CheckAvailability to check availability. To choose frame source in runtime, you can deactive AR Foundation GameObjects and set all required values of all frame sources for availability check, and active AR Foundation GameObjects when this frame source is chosen.


MonoBehaviour Messages

private void OnEnable()

private void OnDisable()

protected virtual void Awake()

protected virtual void OnApplicationPause(bool pause)

protected virtual void OnDestroy()


Fields

EnableColorInput

C#

public bool EnableColorInput

If color image is used as frame input. Color image is usefull when recording a colored eif file, but not necessary for all EasyAR algorithms.

AttemptUpdate

C#

public bool AttemptUpdate

If the device supports AR Foundation but does not have the necessary software, some platforms allow prompting the user to install or update the software. If this field is true, a software update will be attempted. If the appropriate software is not installed or out of date, and this field is false, then this frame source will not be available.

OptimizeConfigurationForTracking

C#

public bool OptimizeConfigurationForTracking

Optimize ARCameraManager.currentConfiguration if it does not meet basic requirement for some of EasyAR features like Mega. Turn it off if you want full control of configuration choosing.


Properties

IsCameraUnderControl

C#

internal protected override bool IsCameraUnderControl { }

Provide only when creating a new frame source. It will only be accessed during ARSession.Assemble .

When the value is ture, the session will update camera transform depending on the center mode and render camera images.

When creating a HMD extension, it should be false. You should have full control of the 3D camera in the scene. You should handle camera rendering, especially in VST.

IsHMD

C#

internal protected override bool IsHMD { }

Provide only when creating a new frame source. It will only be accessed during ARSession.Assemble .

If the frame source represent head mounted displays. If true, diagnostics will be displayed on a 3D board in from of camera.

Some frame filter may work different on devices.

Display

C#

internal protected override IDisplay Display { }

Provide only when creating a new frame source. It will only be accessed during ARSession.Assemble .

Provide display system information. You can use Display.DefaultSystemDisplay or Display.DefaultHMDDisplay for default display.

IsAvailable

C#

internal protected override Optional<bool> IsAvailable { }

Provide only when creating a new frame source. It will only be accessed during ARSession.Assemble .

If the frame source is available.

If the value equals null, FrameSource.CheckAvailability will be called and the value will be accessed after Coroutine finish.

AvailableCenterMode

C#

internal protected override IReadOnlyList< ARSession.ARCenterMode > AvailableCenterMode { }

Provide only when creating a new frame source. It will only be accessed during ARSession.Assemble .

All available center modes.

CameraFrameStarted

C#

internal protected override bool CameraFrameStarted { }

Provide only when creating a new frame source. It will be accessed during the whole life time of ARSession .

If the camera frame has started to input.

DeviceCameras

C#

internal protected override List< FrameSourceCamera > DeviceCameras { }

Provide only when creating a new frame source. It will be accessed when FrameSource.CameraFrameStarted is true.

Device camera to provide camera frame data. The list must contain all cameras if camera frames are provided by multiple cameras.

Make sure the value is correct when FrameSource.CameraFrameStarted is true.

Camera

C#

internal protected override Camera Camera { }

Provide only when creating a new frame source. It will only be accessed during ARSession.Assemble .

On desktop or mobile phones, it represents the Camera in the virtual world in reflection of real world camera device, its projection matrix and transform will be set to reflect the real world camera, and it is controlled by EasyAR. On head mounted displays, it is only used to display some diagnostics message in front of your eyes, it is not used for camera image rendering, it is not controled by EasyAR.

ReceivedFrameCount

C#

public int ReceivedFrameCount { get; }

Received frame count. Usually used for debug. There are usually hardware issues if this value stop to increase, and re-plug may help when using some devices like Nreal.


Methods

OnSessionStart

C#

private override void OnSessionStart( ARSession session)

Provide only when creating a new frame source. It will only be accessed during ARSession.StartSession .

Handle session start if the frame source was assembled into ARSession.Assembly . It is designed for lazy initialization and you can do AR specific initialization work in the method.

OnSessionStop

C#

private override void OnSessionStop()

Provide only when creating a new frame source. It will be accessed during ARSession.StopSession or other session stop/break procedure.

Handle session stop if the frame source was assembled into ARSession.Assembly . You can use this method to destroy and resources created in ARSession.StartSession and during the session running and resotre inner state. It is ensured to be called before session destroy. If the frame source was destroyed before session, it will not be called and session will break.

CheckAvailability

C#

private override System.Collections.IEnumerator CheckAvailability()

Provide only when creating a new frame source. It will only be accessed during ARSession.Assemble .

Coroutine to check frame source availability when FrameSource.IsAvailable equals null.

TryAcquireBuffer

C#

protected Optional< Buffer > TryAcquireBuffer(int size)

Try acquire buffer from buffer pool.