Table of Contents

Class CameraDevice

Manages a camera device.

public sealed class CameraDevice : StatefulResource
Inheritance
object
CameraDevice
Inherited Members
Extension Methods

Constructors

CameraDevice(string)

public CameraDevice(string cameraId)

Parameters

cameraId string

Fields

CameraId

The ID of the camera.

public readonly string CameraId

Field Value

string

NativeProxy

Native callback handler.

public readonly CameraDevice.Proxy NativeProxy

Field Value

CameraDevice.Proxy

Methods

CreateContinuousPipeline(Resolution, CaptureTemplate, StreamUseCase, GraphicsFormat)

Creates a continuous capture pipeline (session + linked YUV to RGBA converter) for use.

public CapturePipeline<ContinuousCaptureSession>? CreateContinuousPipeline(Resolution resolution, CaptureTemplate template = CaptureTemplate.Preview, StreamUseCase streamUseCase = StreamUseCase.None, GraphicsFormat textureFormat = null)

Parameters

resolution Resolution
template CaptureTemplate
streamUseCase StreamUseCase
textureFormat GraphicsFormat

See YUVConverter(Resolution, ComputeShaderKernel, GraphicsFormat) for default texture format.

Returns

CapturePipeline<ContinuousCaptureSession>

The created pipeline, or null if creation failed.

CreateContinuousSession(Resolution, CaptureTemplate, StreamUseCase)

Creates a continuous capture session for use.

public ContinuousCaptureSession CreateContinuousSession(Resolution resolution, CaptureTemplate template = CaptureTemplate.Preview, StreamUseCase streamUseCase = StreamUseCase.None)

Parameters

resolution Resolution

The capture resolution. Must be from SupportedResolutions.

template CaptureTemplate

The template to use for the captures.

streamUseCase StreamUseCase

The stream use case for this session. Must be from SupportedStreamUseCases or None.

Returns

ContinuousCaptureSession

Returns the session. Check State (inherited by ContinuousCaptureSession) for the state of the session.

Remarks

To shut down and dispose the session, use DisposeAsync() (inherited by ContinuousCaptureSession).

Exceptions

ObjectDisposedException

CreateGLESSessionAsync(Resolution, CaptureTemplate, StreamUseCase, GraphicsFormat)

Creates a generic OpenGL-ES based capture session.

public ValueTask<GLESCaptureSession> CreateGLESSessionAsync(Resolution resolution, CaptureTemplate template = CaptureTemplate.Preview, StreamUseCase streamUseCase = StreamUseCase.None, GraphicsFormat textureFormat = null)

Parameters

resolution Resolution

The capture resolution. Must be from SupportedResolutions.

template CaptureTemplate

The template to use for the captures.

streamUseCase StreamUseCase

The stream use case for this session. Must be from SupportedStreamUseCases or None.

textureFormat GraphicsFormat

The output texture format for the converted frames. See GLESCaptureSession(Resolution, GraphicsFormat) for default.

Returns

ValueTask<GLESCaptureSession>

Returns the session. Check State (inherited by GLESCaptureSession) for the state of the session.

Remarks

This initializes a native capture session backed by a SurfaceTexture and a GLES conversion job. The returned session must be started manually (e.g., via its run loop or single-run methods) and disposed using DisposeAsync().

Exceptions

ObjectDisposedException

CreateOnDemandPipeline(Resolution, StreamUseCase, GraphicsFormat)

Creates an on-demand capture pipeline (session + linked YUV to RGBA converter) for use.

public CapturePipeline<OnDemandCaptureSession>? CreateOnDemandPipeline(Resolution resolution, StreamUseCase streamUseCase = StreamUseCase.None, GraphicsFormat textureFormat = null)

Parameters

resolution Resolution
streamUseCase StreamUseCase
textureFormat GraphicsFormat

See YUVConverter(Resolution, ComputeShaderKernel, GraphicsFormat) for default texture format.

Returns

CapturePipeline<OnDemandCaptureSession>

The created pipeline, or null if creation failed.

CreateOnDemandSession(Resolution, StreamUseCase)

Creates an on-demand capture session for use.

public OnDemandCaptureSession CreateOnDemandSession(Resolution resolution, StreamUseCase streamUseCase = StreamUseCase.None)

Parameters

resolution Resolution

The capture resolution. Must be from SupportedResolutions.

streamUseCase StreamUseCase

The stream use case for this session. Must be from SupportedStreamUseCases or None.

Returns

OnDemandCaptureSession

Returns the session. Check State (inherited by OnDemandCaptureSession) for the state of the session.

Remarks

To shut down and dispose the session, use DisposeAsync() (inherited by OnDemandCaptureSession).

Exceptions

ObjectDisposedException

DisposeAsync()

Closes the camera (if not already closed) and releases native resources.

public ValueTask DisposeAsync()

Returns

ValueTask

~CameraDevice()

protected ~CameraDevice()

ThrowIfDisposed()

protected override void ThrowIfDisposed()

Events

OnDeviceClosed

Invoked when the camera is closed, along with the camera ID.

public event Action<string>? OnDeviceClosed

Event Type

Action<string>

OnDeviceDisconnected

Invoked when the camera is disconnected, along with the camera ID.

public event Action<string>? OnDeviceDisconnected

Event Type

Action<string>

OnDeviceErred

Invoked when the camera encounters an error, along with the camera ID.

public event Action<string, CameraDevice.ErrorCode>? OnDeviceErred

Event Type

Action<string, CameraDevice.ErrorCode>

OnDeviceOpened

Invoked when the camera is opened, along with the camera ID.

public event Action<string>? OnDeviceOpened

Event Type

Action<string>