MLCamera Overview
The Magic Leap 2 MLCamera
API allows developers to capture real and virtual content inside their applications.
Logical Cameras
Magic Leap 2 allows developers to access two Logical Cameras from the same physical camera. The camera streams are accessed as devices in the Unity API and have the following identifiers:
MLCamera.Identifier.Main
- 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.MLCamera.Identifier.CV
- best used for Computer vision scenarios, uncompressed, raw frames.
If you use this device to do CV in you application, you will be able to use the record/stream gameplay using the Capture Service, but you will not be able to perform Image or marker tracking using the SDK.
This features requires the CAMERA
permission to be requested at runtime and enabled in your project's Manifest Settings (Edit > Project Settings > Magic Leap > Manifest Settings).
Capture Output
Format | Camera | Mode | Capture Type |
---|---|---|---|
YUV | Main | Real | Preview/Video/Image |
YUV | CV | Real | Video/Image |
RGBA | Main | MR/Virtual | Video/Image |
RGBA | CV | Real | Video |
JPEG | Main | Real/MR/Virtual | Image |
MLCameraCaptureType_Image
- Capture an ImageMLCameraCaptureType_Video
- Capture VideoMLCameraCaptureType_Preview
- Capture a video and and access the raw buffer of the frames
Guides
📄️ API Overview
This guide provides a walk through of creating a custom camera capture script. The sections in this guide were written in a linear flow although each section can also be referenced individually.
📄️ Visualize Camera Output
This section includes details on rendering the Magic Leap's camera output on a Raw Image UI Component. When receiving camera output developers can query the format using the MLCamera.CameraOutput.Format property.
📄️ Intrinsic/Extrinsic Parameters
This section includes details on reading the Intrinsic and Extrinsic parameters from the Magic Leap camera. These values can be queried using the MLCamera.ResultExtras value provided in the Camera Capture callbacks.
📄️ MLCamera Examples
This section includes a simple camera example. A detailed explanation of each function can be found in the Camera Overview guide.