Table of Contents

Class CameraDeviceFrameSource

Namespace
easyar
Assembly
EasyAR.Sense.dll

Controls the easyar.CameraDevice in the scene, extending functionality in the Unity environment.

This frame source is not a motion-tracking device and will not output motion data in ARSession.

[RequireComponent(typeof(CameraDeviceDisplay))]
public class CameraDeviceFrameSource : FrameSource
Inheritance
CameraDeviceFrameSource
Derived
Inherited Members

Fields

CameraOpenIndex

The device index used when opening the camera, used when CameraOpenMethod == DeviceIndex, effective only if modified before the DeviceOpened event.

[HideInInspector]
[SerializeField]
public int CameraOpenIndex

Field Value

CameraOpenMethod

The method used when opening the camera, effective only if modified before the DeviceOpened event.

[HideInInspector]
[SerializeField]
public CameraDeviceFrameSource.CameraDeviceOpenMethod CameraOpenMethod

Field Value

CameraOpenType

The camera type used when opening the camera, used when CameraOpenMethod == PreferredType or SpecificType, effective only if modified before the DeviceOpened event.

[HideInInspector]
[SerializeField]
public CameraDeviceType CameraOpenType

Field Value

Properties

AndroidCameraApiType

On Android, can be used to get the camera API used (camera1 or camera2). Available only when Opened is true.

public AndroidCameraApiType AndroidCameraApiType { get; }

Property Value

AvailableCenterMode

Provided only when creating a new frame source. It is accessed solely during the Assemble() process.

All available center modes.

protected override IReadOnlyList<ARSession.ARCenterMode> AvailableCenterMode { get; }

Property Value

Camera

Provided only when creating a new frame source. It is only accessed during the Assemble() process.

On desktop or mobile devices, this camera represents the Camera corresponding to the real-world camera device in the virtual world; its projection matrix and position will correspond to the real camera and be controlled by EasyAR. On HMDs, 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; }

Property Value

CameraCandidate

Alternative to Camera; if not set, Camera.main will be used.

public Camera CameraCandidate { get; set; }

Property Value

CameraCount

Gets the number of cameras recognized by the operating system.

public static int CameraCount { get; }

Property Value

CameraFrameStarted

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

Whether camera frame input has started.

protected override bool CameraFrameStarted { get; }

Property Value

CameraType

The camera type. Available only when Opened is true.

public CameraDeviceType CameraType { get; }

Property Value

DesiredAndroidCameraApiType

Desired Android Camera Api, effective only if modified before the DeviceOpened event.

If not set, it will be chosen based on DesiredCameraPreference.

public Optional<AndroidCameraApiType> DesiredAndroidCameraApiType { get; set; }

Property Value

DesiredCameraPreference

Preference settings used when creating the camera device, effective only if modified before the session starts.

public Optional<CameraDevicePreference> DesiredCameraPreference { get; set; }

Property Value

DesiredFocusMode

Desired focus mode, effective only if modified before the DeviceOpened event.

Note: Subject to hardware or system limitations, focus switching may not work on some devices. If not set, it will be chosen based on DesiredCameraPreference.

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

Property Value

DesiredSize

Desired camera image size, effective only if modified before the DeviceOpened event.

Will use the closest size in SupportedSize. If not set, the default value will be used.

public Optional<Vector2Int> DesiredSize { get; set; }

Property Value

DeviceCameras

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

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

Ensure the value is correct when CameraFrameStarted is true.

protected override List<FrameSourceCamera> DeviceCameras { get; }

Property Value

Display

Provided only when creating a new frame source. It is accessed solely 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

FocusMode

Focus mode. Only available when Opened is true.

public CameraDeviceFocusMode FocusMode { set; }

Property Value

FrameRateRange

Frame rate range. Only available when Opened is true.

public Vector2 FrameRateRange { get; }

Property Value

FrameRateRangeIndex

Index of the current frame rate range of the device. Only available when Opened is true.

public int FrameRateRangeIndex { get; set; }

Property Value

Index

The camera index. Available only when Opened is true.

public int Index { get; }

Property Value

IsAvailable

Provided only when creating a new frame source. It is accessed solely during the Assemble() process.

Whether the current frame source is available.

If the value equals 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. It is accessed solely during the Assemble() process.

When the value is true, the session updates the camera transform and renders the camera image.

When creating an HMD extension, 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. It is only accessed during the Assemble() process.

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

Some frame filters behave differently on HMDs.

protected override bool IsHMD { get; }

Property Value

Opened

Whether the camera is open.

public bool Opened { get; }

Property Value

Parameters

Camera parameters. Only available when Opened is true.

public CameraParameters Parameters { get; set; }

Property Value

Size

Current image size. Only available when Opened is true.

set will use the closest size in SupportedSize.

If the image size is modified during FrameRecorder recording, recording data will stop updating; recording must be stopped and restarted.

public Vector2Int Size { get; set; }

Property Value

SupportedFrameRateRange

All supported frame rate ranges of the current device. Only available when Opened is true.

public List<Vector2> SupportedFrameRateRange { get; }

Property Value

SupportedSize

All image sizes supported by the current device. Available only when Opened is true.

public List<Vector2Int> SupportedSize { get; }

Property Value

Methods

AutoFocus()

Does auto focus once. It is only available when FocusMode is Normal or Macro.

public bool AutoFocus()

Returns

Close()

Closes the device.

public void Close()

OnSessionStart(ARSession)

Provided only when creating a new frame source. It is accessed solely during the StartSession() process.

Handles session startup if this frame source is assembled into Assembly. This method is designed for lazy initialization; you can perform AR-specific initialization here.

protected override void OnSessionStart(ARSession session)

Parameters

session

OnSessionStop()

Provided only when creating a new frame source. It is accessed during StopSession(bool) or other session stop/corruption processes.

Handles session stop if this frame source is assembled into Assembly. Use this method to destroy resources created during StartSession() and session runtime, 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() after startup.

Available only after the session starts.

public void Open()

SetFlashTorch(bool)

Sets the flash torch mode. Available only when Opened is true.

public bool SetFlashTorch(bool on)

Parameters

on

Returns

Events

DeviceClosed

The device closing event.

public event Action DeviceClosed

Event Type

DeviceOpened

The device opening event, a bool value indicating success.

public event Action<bool, PermissionStatus, string> DeviceOpened

Event Type

DeviceStateChanged

The event of device disconnection or preemption making it unusable (only Windows).

public event Action<CameraState> DeviceStateChanged

Event Type