Unity Editor version: 2022.3.11f1
ML2 OS version: Version 1.5.0
Unity SDK version: 2.0.0
Host OS: (Windows/MacOS): Windows 11 Pro 23H2 22631.3235
On the Sensors | MagicLeap Developer Documentation page it is said that:
- Operating Modes - SR (60Hz), LR (5Hz), SR+LR (5Hz), SR(~50+Hz) + LR(1Hz)
When trying to get SR+LR Stream e.g. as
Streams = MLDepthCamera.Stream.LongRange | MLDepthCamera.Stream.ShortRange,
than it leads to getting a runtime error:
Error: MLDepthCameraConnect in the Magic Leap API failed. Reason: MLResult_InvalidParam
UnityEngine.XR.MagicLeap.MLResult:DidNativeCallSucceed(Code, String, Predicate`1, Boolean)
UnityEngine.XR.MagicLeap.MLDepthCamera:InternalConnect(Settings)"
Which is not a suprise as the enum has no [Flags] attribute.
I Create the DepthCamera by teh next code:
private bool CreateDepthCamera()
{
uint longRange = (uint)MLDepthCamera.FrameType.LongRange;
uint shortRange = (uint)MLDepthCamera.FrameType.ShortRange;
MLDepthCamera.StreamConfig[] config = new MLDepthCamera.StreamConfig[Math.Max(longRange, shortRange) + 1];
config[longRange].Flags = (uint)depthCamCaptureFlags;
config[longRange].Exposure = 1600;
config[longRange].FrameRateConfig = depthLongRangeFPS;
config[shortRange].Flags = (uint)depthCamCaptureFlags;
config[shortRange].Exposure = 375;
config[shortRange].FrameRateConfig = depthShortRangeFPS;
depthSettings = new MLDepthCamera.Settings()
{
//Streams = MLDepthCamera.Stream.LongRange | MLDepthCamera.Stream.ShortRange, // leads to: Failed to connect to depth camera: InvalidParam. Stream Enum is not defined as [Flags] !
Streams = depthStream,
StreamConfig = config
};
MLDepthCamera.SetSettings(depthSettings);
If I set only SR or LR, than I change the Setting by calling
MLDepthCamera.UpdateSettings(depthSettings);
then switching between ShortRange / LongRange and getting next depth frame takes more than 2700 ms.
My Question is: How can I successfully get a SR+LR (5Hz) and SR(~50+Hz) + LR(1Hz) as it is written in the documentation?