Skip to main content
Version: 20 Mar 2024

MLCamera

NameSpace: MagicLeap

Provides a multithreadig implementation of the camera api. Handles pause behavior automatically.

Inherits from:
MLCameraBase,
MLAPIBase

Public Fields

IsPaused

Whether the camera is currently paused


public bool IsPaused { get; set; }


Public Methods

Task< MLResult > CaptureImageAsync

Asynchronously capture still image. Result will be availble via the MLCamera.OnRawImageAvailable event.

public Task< MLResult > CaptureImageAsync(
uint numImages =1
)

Parameters

TypeNameDescription
uintnumImagesNumber of images to capture. Valid range is 1-10

Task< MLResult > CapturePreviewStartAsync

Asynchronously start preview capture The captured preview YUV frames will be returned to the application via OnPreviewCaptureCompleted. Use CapturePreviewStop or CapturePreviewStopAsync to stop the capture.

public Task< MLResult > CapturePreviewStartAsync()

Task< MLResult > CapturePreviewStopAsync

Asynchronously stop preview capture.

public Task< MLResult > CapturePreviewStopAsync()

Task< MLResult > CaptureVideoStartAsync

Asynchronously start video capture of either encoded video or YUV/RGBA frames. YUV/RGBA frames are provides through callback. For encoded video capture valid MediaRecorder object should be configured in the PrepareCapture(CaptureConfig, out Metadata) call. The captured video YUV/RGBA frames will be returned via the OnRawVideoFrameAvailable and OnRawVideoFrameAvailable_NativeCallbackThread events.

public Task< MLResult > CaptureVideoStartAsync()

Task< MLResult > CaptureVideoStopAsync

Asynchronously stop video capture. Should only be called at least 500ms after CaptureVideoStart or CaptureVideoStartAsync.

public Task< MLResult > CaptureVideoStopAsync()

new static MLCamera Create

public static new static MLCamera Create()

MLCamera CreateAndConnect

Creates an MLCamera instance and connects the camera device. Will return null if the [ConnectContext] is incorrectly configured. For example, if the context's Flags are set to MLCamera.ConnectFlag.VirtualOnly when targeting the CV camera.

public static MLCamera CreateAndConnect(
ConnectContext connectContext
)

Parameters

TypeNameDescription
ConnectContextconnectContextConnection settings

Returns: MLCamera instance if connection was successful, null otherwise


Task< MLCamera > CreateAndConnectAsync

Asynchronously creates an MLCamera instance and connects the camera device. Will return null if the [ConnectContext] is incorrectly configured. For example, if the context's Flags are set to MLCamera.ConnectFlag.VirtualOnly when targeting the CV camera.

public static Task< MLCamera > CreateAndConnectAsync(
ConnectContext connectContext
)

Parameters

TypeNameDescription
ConnectContextconnectContextConnection settings

Returns: MLCamera instance if connection was successful, null otherwise


Task< MLResult > DisconnectAsync

Asynchronously isconnect the camera. Should call MLCamera.Connect() again on this instance or create a new MLCamera object using MLCamera.CreateAndConnect() function.

public Task< MLResult > DisconnectAsync()

Task< MLResult > PreCaptureAEAWBAsync

Trigger asynchronous AEAWB Convergence. This API triggers AEAWB sequence and completes when AEAWB convergence has been achieved. The users can either trigger and converge AEAWB metadata settings or use this API.

public Task< MLResult > PreCaptureAEAWBAsync()

Protected Methods

OnApplicationPause

Callback sent to all MagicLeap APIs on application pause.

protected virtual override void OnApplicationPause(
bool pauseStatus
)

Parameters

TypeNameDescription
boolpauseStatusTrue if the application is paused, else False.

Reimplements: OnApplicationPause


Public Events

OnCameraPaused

Event that gets fired when the camera is paused

public Action OnCameraPaused()

OnCameraResumed

Event that gets fired when the camera is resumed after a pause

public Action OnCameraResumed()