Skip to main content
Version: 20 Mar 2024

MLCamera (Deprecated)

WARNING

This content is being deprecated. For the latest information about MLCamera, see Camera2.

Changes include:

  • Additional camera stream and reassignment of tasks across streams
  • Removal of support for RGB/RGBA

The Magic Leap 2 MLCamera API allows developers to capture real and virtual content inside their applications. While the Magic Leap 2 has only one camera for capturing content, two separate streams can be access from the camera at the same time. This allows you to create applications that can stream the user's point of view, while using the camera to perform computer vision tasks.

Camera Streams

Magic Leap 2 allows developers to access two streams from the same physical camera. The camera streams are accessed as devices in the Unity API and have the following identifiers:

  1. Main Camera - provides access to compressed video and still images. This device allows you to capture virtual, real-world, mixed reality content and is the performed choice if you are not performing computer vision tasks on the output or if it is being used for streaming, broadcasting, or images.

  2. CV Camera - best used for Computer vision scenarios, uncompressed, raw frames. If you use this device to do CV in you application, you can use the record/stream gameplay using the Capture Service, but you cannot perform Image or marker tracking using the SDK.

You can use the same stream to capture different types of content. For example, you can capture Video, Images, and a Preview from the Main Camera stream, while also using the CV Camera at the same time.

Mixed Reality Capture

The Main Camera stream is the only stream that can capture Mixed Reality content. However, the Mixed Reality Capture stream only supports a single concurrent capture mode which means that you need to choose whether to capture Video OR Images but not both.

Stream Capabilities

This section details the supported Resolution, Capture Type, Formats and Frame Rates. The following table provides general information about each of the supported formats.

  • Camera type: [Main, CV]
  • Mode: [Real, MR (Mixed Reality), Virtual]
  • Capture type: [Preview, Video, Image]

These are formats supported:

FormatCameraModeCapture Type
YUVMainRealPreview/Video/Image
YUVCVRealVideo/Image
RGBAMainMR/VirtualVideo/Image
RGBACVRealVideo
JPEGMainReal/MR/VirtualImage

Main Camera Stream

The table below shows which output formats are supported when capturing using the Main Camera Stream.

Camera Mode Resolution Capture Type Formats FrameRate
MainCam_Only640x480
1280x720
1280x960
1440x1080
1920x1080
2048x1536
PreviewYUV15/30/60
ImageYUV/JPEG15/30/60
VideoYUV/RGB/Compressed15/30/60

2880x2160
3840x2160
4096x3072

PreviewYUV15/30
ImageYUV/JPEG15/30
VideoYUV/RGB/Compressed15/30

CV Camera Stream

The table below shows which output formats are supported when capturing using the Computer Vision Camera.

Camera Mode Resolution Capture Type Formats FrameRate
CVCam_Only640x480
1280x720
1280x960
1440x1080
1920x1080
2048x1536
ImageYUV15/30/60
VideoYUV/RGB                        15/30/60

2880x2160
3840x2160
4096x3072

ImageYUV15/30
VideoYUV/RGB 15/30
info
  • 15Fps only supported in Auto Exposure Mode.
  • When multiple streams are configured frame rate is constrained by max resolution.
  • FrameRate_None can be used when only Image capture_type is used.

Mixed Reality / Virtual Only Capture

The table below shows which output formats are supported when capturing Virtual and Mixed Reality Content.

Camera Mode Resolution Capture Type Formats FrameRate
MainMR/Virtual_Only648x720 ImageRBG/JPEG30/60
VideoRGB/Compressed30/60
960x720 ImageRBG/JPEG30/60
VideoRGB/Compressed30/60
972x1080 ImageRBG/JPEG30/60
VideoRGB/Compressed30/60
1440x1080ImageRBG/JPEG30/60
VideoRGB/Compressed30/60
1944x2160ImageRBG/JPEG30
VideoRGB/Compressed30
2880x2160ImageRBG/JPEG30
VideoRGB/Compressed30
info

Quality and frame rate provided during connection should match the resolution and framerate that was used when preparing capture.

Upgrading from Magic Leap 1

The Magic Leap 2 offers a new Unified Camera API, which means the Mixed Reality, Computer Vision, and Standard camera streams can be accessed with the same set of APIs.

Additionally, the Magic Leap 2 allows access to two camera devices - Main Camera (Camera 0) and Computer Vision Camera (Camera 1), which allows for unique application features, such as streaming a user's point of view while tracking markers or performing custom computer vision tasks.

While the Magic Leap 2's APIs are new, the API semantics are similar to the Magic Leap 1 MLCamera API. The Magic Leap SDK provides samples that can be used for reference when creating or migrating your application.