Class CameraDevice
- Namespace
- Uralstech.UXR.QuestCamera
A wrapper for a native Camera2 CameraDevice.
public class CameraDevice : AndroidJavaProxy
- Inheritance
-
objectCameraDevice
Constructors
CameraDevice(string)
public CameraDevice(string id)
Parameters
idstring
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
Methods
CreateContinuousCaptureSession(Resolution, CaptureTemplate)
Creates a new repeating/continuous capture session for use.
public CapturePipeline<ContinuousCaptureSession>? CreateContinuousCaptureSession(Resolution resolution, CaptureTemplate captureTemplate = CaptureTemplate.Preview)
Parameters
resolutionResolutionThe resolution of the capture.
captureTemplateCaptureTemplateThe 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
resolutionResolution
Returns
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
resolutionResolutioncaptureTemplateCaptureTemplate
Returns
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
resolutionResolutionThe resolution of the capture.
captureTemplateCaptureTemplateThe 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
methodNamestringjavaArgsnint
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
timeoutTimeSpanMaximum time to wait.
onTimeoutActionThe action to perform when the
timeoutis reached.timeoutModeWaitTimeoutModeMode 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
tokenCancellationToken
Returns
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>