Table of Contents

Class CameraDevice

A wrapper for a native Camera2 CameraDevice.

public class CameraDevice : AndroidJavaProxy
Inheritance
object
CameraDevice

Constructors

CameraDevice(string)

public CameraDevice(string id)

Parameters

id string

Fields

CameraId

The ID of the camera being wrapped.

public readonly string CameraId

Field Value

string

_cameraDevice

protected AndroidJavaObject? _cameraDevice

Field Value

AndroidJavaObject?

Properties

CurrentState

The current assumed state of the native CameraDevice wrapper.

public NativeWrapperState CurrentState { get; }

Property Value

NativeWrapperState

Methods

CreateContinuousCaptureSession(Resolution, CaptureTemplate)

Creates a new repeating/continuous capture session for use.

public CapturePipeline<ContinuousCaptureSession>? CreateContinuousCaptureSession(Resolution resolution, CaptureTemplate captureTemplate = CaptureTemplate.Preview)

Parameters

resolution Resolution

The resolution of the capture.

captureTemplate CaptureTemplate

The capture template to use for the capture

Returns

CapturePipeline<ContinuousCaptureSession>

A new capture session wrapper, or null if any errors occurred.

Remarks

Once you have finished using the capture session, call DisposeAsync() to close and dispose the session to free up native and compute shader resources.

CreateOnDemandCaptureSession(Resolution)

Creates a new on-demand capture session for use.

public CapturePipeline<OnDemandCaptureSession>? CreateOnDemandCaptureSession(Resolution resolution)

Parameters

resolution Resolution

Returns

CapturePipeline<OnDemandCaptureSession>

CreateOnDemandSurfaceTextureCaptureSession(Resolution, CaptureTemplate)

Creates a new on-demand OpenGL SurfaceTexture based capture session for use. Equivalent to OnDemandCaptureSession.

public OnDemandSurfaceTextureCaptureSession? CreateOnDemandSurfaceTextureCaptureSession(Resolution resolution, CaptureTemplate captureTemplate = CaptureTemplate.Preview)

Parameters

resolution Resolution
captureTemplate CaptureTemplate

Returns

OnDemandSurfaceTextureCaptureSession

CreateSurfaceTextureCaptureSession(Resolution, CaptureTemplate)

Creates a new OpenGL SurfaceTexture based capture session for use. Equivalent to ContinuousCaptureSession.

public SurfaceTextureCaptureSession? CreateSurfaceTextureCaptureSession(Resolution resolution, CaptureTemplate captureTemplate = CaptureTemplate.Preview)

Parameters

resolution Resolution

The resolution of the capture.

captureTemplate CaptureTemplate

The capture template to use for the capture

Returns

SurfaceTextureCaptureSession

A new capture session wrapper, or null if any errors occurred.

Remarks

This experimental capture session uses a native OpenGL texture to capture images for better performance and requires OpenGL ES 3.0 as the project's graphics API. Works with single and multi-threaded rendering.

Once you have finished using the capture session, call DisposeAsync() to dispose the session to free up native resources.

DisposeAsync()

Closes and disposes the camera device.

public ValueTask DisposeAsync()

Returns

ValueTask

~CameraDevice()

protected ~CameraDevice()

Invoke(string, nint)

public override nint Invoke(string methodName, nint javaArgs)

Parameters

methodName string
javaArgs nint

Returns

nint

WaitForInitialization()

Waits until the CameraDevice opens or errs out.

public WaitUntil WaitForInitialization()

Returns

WaitUntil

WaitForInitialization(TimeSpan, Action, WaitTimeoutMode)

Waits until the CameraDevice opens or errs out.

public WaitUntil WaitForInitialization(TimeSpan timeout, Action onTimeout, WaitTimeoutMode timeoutMode = null)

Parameters

timeout TimeSpan

Maximum time to wait.

onTimeout Action

The action to perform when the timeout is reached.

timeoutMode WaitTimeoutMode

Mode in which to measure time to determine timeout.

Returns

WaitUntil

WaitForInitializationAsync(CancellationToken)

Waits until the CameraDevice opens or errs out.

public Task<bool> WaitForInitializationAsync(CancellationToken token = default)

Parameters

token CancellationToken

Returns

Task<bool>

true if the device was opened successfully, false otherwise.

Events

OnDeviceClosed

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

public event Action<string?>? OnDeviceClosed

Event Type

Action<string>

Remarks

The camera ID may be null if the camera could not be opened in the first place.

OnDeviceDisconnected

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

public event Action<string>? OnDeviceDisconnected

Event Type

Action<string>

OnDeviceErred

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

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

Event Type

Action<string, CameraDevice.ErrorCode>

Remarks

The camera ID may be null if the camera could not be opened in the first place.

OnDeviceOpened

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

public event Action<string>? OnDeviceOpened

Event Type

Action<string>