-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f108be2
commit 4cece36
Showing
65 changed files
with
2,912 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
// %BANNER_BEGIN% | ||
// --------------------------------------------------------------------- | ||
// %COPYRIGHT_BEGIN% | ||
// Copyright (c) 2022-2023 Magic Leap, Inc. All Rights Reserved. | ||
// Use of this file is governed by the Software License Agreement, located here: https://www.magicleap.com/software-license-agreement-ml2 | ||
// Terms and conditions applicable to third-party materials accompanying this distribution may also be found in the top-level NOTICE file appearing herein. | ||
// %COPYRIGHT_END% | ||
// --------------------------------------------------------------------- | ||
// %BANNER_END% | ||
|
||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace UnityEngine.XR.MagicLeap | ||
{ | ||
public sealed partial class MLEyeCamera : MLAutoAPISingleton<MLEyeCamera> | ||
{ | ||
/// <summary> | ||
/// The maximum number of eye camera frames. | ||
/// </summary> | ||
public const int MaxFrameCount = 4; | ||
|
||
/// <summary> | ||
/// The enumerated value representing which eye cameras are currently active. | ||
/// </summary> | ||
/// <returns></returns> | ||
public static MLEyeCameraIdentifier ActiveCameras => (MLEyeCameraIdentifier)Instance.settings.Cameras; | ||
|
||
/// <summary> | ||
/// The number of active eye cameras. | ||
/// </summary> | ||
/// <value></value> | ||
public static int ActiveCamerasCount | ||
{ | ||
get | ||
{ | ||
int count = 0; | ||
|
||
if (ActiveCameras.HasFlag(MLEyeCameraIdentifier.LeftTemple)) | ||
count++; | ||
if (ActiveCameras.HasFlag(MLEyeCameraIdentifier.LeftNasal)) | ||
count++; | ||
if (ActiveCameras.HasFlag(MLEyeCameraIdentifier.RightNasal)) | ||
count++; | ||
if (ActiveCameras.HasFlag(MLEyeCameraIdentifier.RightTemple)) | ||
count++; | ||
|
||
return count; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Converts an image frame data pointer into a byte array. | ||
/// </summary> | ||
/// <param name="imageFrame">The associated eye camera frame buffer for an eye camera.</param> | ||
/// <param name="byteArray">The image data from the native eye camera data as a byte array.</param> | ||
public static void CopyImageFrameDataToByteArray(EyeCameraFrameBuffer imageFrame, ref byte[] byteArray) => Marshal.Copy(imageFrame.Data, byteArray, 0, byteArray.Length); | ||
|
||
/// <summary> | ||
/// Polls for Frames. Returns EyeCameraData with this latest data when available. | ||
/// If there are no new camera frames within the timeout_ms duration then the API will return MLResult_Timeout. | ||
/// </summary> | ||
/// <param name="outData">Eye camera data to be output.</param> | ||
/// <param name="timeoutMS">Timeout in milliseconds.</param> | ||
/// <returns> | ||
/// MLResult.Result will be <c>MLResult.Code.Ok</c> if succesfully fetched the camera frames and released the native data. | ||
/// MLResult.Result will be <c>MLResult.Code.Timeout</c> returned because no new frame available at this time. | ||
/// MLResult.Result will be <c>MLResult.Code.InvalidParam</c> if one of the parameters is invalid. | ||
/// MLResult.Result will be <c>MLResult.Code.UnspecifiedFailure</c> if the operation failed due to an internal error. | ||
/// </returns> | ||
public static MLResult GetLatestCameraData(out EyeCameraData outData, UInt64 timeoutMS) => Instance.InternalMLEyeCameraGetLatestCameraData(out outData, timeoutMS); | ||
|
||
/// <summary> | ||
/// Update the eye camera settings. | ||
/// </summary> | ||
/// <param name="cameras">The specific eye cameras that will be active with the updated settings.</param> | ||
/// <returns> | ||
/// MLResult.Result will be <c>MLResult.Code.Ok</c> if the settings updated successfully. | ||
/// MLResult.Result will be <c>MLResult.Code.InvalidParam</c> if one of the parameters is invalid. | ||
/// MLResult.Result will be <c>MLResult.Code.UnspecifiedFailure</c> if the operation failed due to an internal error. | ||
/// </returns> | ||
public static MLResult UpdateSettings(MLEyeCameraIdentifier cameras) => Instance.InternalMLEyeCameraUpdateSettings(cameras); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// %BANNER_BEGIN% | ||
// --------------------------------------------------------------------- | ||
// %COPYRIGHT_BEGIN% | ||
// Copyright (c) 2022-2023 Magic Leap, Inc. All Rights Reserved. | ||
// Use of this file is governed by the Software License Agreement, located here: https://www.magicleap.com/software-license-agreement-ml2 | ||
// Terms and conditions applicable to third-party materials accompanying this distribution may also be found in the top-level NOTICE file appearing herein. | ||
// %COPYRIGHT_END% | ||
// --------------------------------------------------------------------- | ||
// %BANNER_END% | ||
|
||
namespace UnityEngine.XR.MagicLeap | ||
{ | ||
using System; | ||
|
||
public sealed partial class MLEyeCamera | ||
{ | ||
/// <summary> | ||
/// Enumeration of all the available eye camera sensors. | ||
/// </summary> | ||
[Flags] | ||
public enum MLEyeCameraIdentifier | ||
{ | ||
/// <summary> | ||
/// None. | ||
/// </summary> | ||
None = 0, | ||
|
||
/// <summary> | ||
/// Left temple eye camera. | ||
/// </summary> | ||
LeftTemple = 1 << 0, | ||
|
||
/// <summary> | ||
/// Left nasal eye camera. | ||
/// </summary> | ||
LeftNasal = 1 << 1, | ||
|
||
/// <summary> | ||
/// Right nasal eye camera. | ||
/// </summary> | ||
RightNasal = 1 << 2, | ||
|
||
/// <summary> | ||
/// Right temple eye camera. | ||
/// </summary> | ||
RightTemple = 1 << 3, | ||
|
||
/// <summary> | ||
/// All Eye cameras. | ||
/// </summary> | ||
All = LeftTemple | LeftNasal | RightNasal | RightTemple | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// %BANNER_BEGIN% | ||
// --------------------------------------------------------------------- | ||
// %COPYRIGHT_BEGIN% | ||
// Copyright (c) 2022-2023 Magic Leap, Inc. All Rights Reserved. | ||
// Use of this file is governed by the Software License Agreement, located here: https://www.magicleap.com/software-license-agreement-ml2 | ||
// Terms and conditions applicable to third-party materials accompanying this distribution may also be found in the top-level NOTICE file appearing herein. | ||
// %COPYRIGHT_END% | ||
// --------------------------------------------------------------------- | ||
// %BANNER_END% | ||
|
||
namespace UnityEngine.XR.MagicLeap | ||
{ | ||
using System; | ||
using System.Diagnostics; | ||
using System.Runtime.InteropServices; | ||
using Native; | ||
public sealed partial class MLEyeCamera | ||
{ | ||
private NativeBindings.MLEyeCameraSettings settings; | ||
|
||
protected override MLResult.Code StartAPI() | ||
{ | ||
Instance.settings = new NativeBindings.MLEyeCameraSettings(1, MLEyeCameraIdentifier.All); | ||
|
||
var resultCode = NativeBindings.MLEyeCameraConnect(ref settings, ref Instance.Handle); | ||
MLResult.DidNativeCallSucceed(resultCode, nameof(NativeBindings.MLEyeCameraConnect)); | ||
return resultCode; | ||
} | ||
|
||
protected override MLResult.Code StopAPI() | ||
{ | ||
var resultCode = NativeBindings.MLEyeCameraDisconnect(Instance.Handle); | ||
MLResult.DidNativeCallSucceed(resultCode, nameof(NativeBindings.MLEyeCameraDisconnect)); | ||
return resultCode; | ||
} | ||
|
||
private MLResult InternalMLEyeCameraGetLatestCameraData(out EyeCameraData outData, UInt64 timeoutMS) | ||
{ | ||
NativeBindings.MLEyeCameraData eyeCameraData = new NativeBindings.MLEyeCameraData(1); | ||
|
||
var resultCode = NativeBindings.MLEyeCameraGetLatestCameraData(Instance.Handle, timeoutMS, ref eyeCameraData); | ||
|
||
outData = new EyeCameraData(eyeCameraData); | ||
|
||
if (!MLResult.DidNativeCallSucceed(resultCode, nameof(NativeBindings.MLEyeCameraGetLatestCameraData))) | ||
return MLResult.Create(resultCode); | ||
|
||
resultCode = NativeBindings.MLEyeCameraReleaseCameraData(Instance.Handle, ref eyeCameraData); | ||
MLResult.DidNativeCallSucceed(resultCode, nameof(NativeBindings.MLEyeCameraReleaseCameraData)); | ||
|
||
return MLResult.Create(resultCode); | ||
} | ||
|
||
private MLResult InternalMLEyeCameraUpdateSettings(MLEyeCameraIdentifier cameras) | ||
{ | ||
Instance.settings = new NativeBindings.MLEyeCameraSettings(1, cameras); | ||
|
||
var resultCode = NativeBindings.MLEyeCameraUpdateSettings(Instance.Handle, ref Instance.settings); | ||
MLResult.DidNativeCallSucceed(resultCode, nameof(NativeBindings.MLEyeCameraUpdateSettings)); | ||
|
||
return MLResult.Create(resultCode); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.