Skip to content

Commit

Permalink
Release v1.12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kgrinberg-ml committed Nov 8, 2023
1 parent 4687f1e commit ea709a1
Show file tree
Hide file tree
Showing 14 changed files with 127 additions and 96 deletions.
19 changes: 6 additions & 13 deletions Assets/MagicLeap/Examples/Scenes/MarkerTracking.unity
Original file line number Diff line number Diff line change
Expand Up @@ -312,12 +312,12 @@ PrefabInstance:
- target: {fileID: 1359980009267695964, guid: 6906f74934047d24e9a47bbdd1afb57a,
type: 3}
propertyPath: m_AnchorMax.x
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1359980009267695964, guid: 6906f74934047d24e9a47bbdd1afb57a,
type: 3}
propertyPath: m_AnchorMax.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5355557165450182212, guid: 6906f74934047d24e9a47bbdd1afb57a,
type: 3}
Expand Down Expand Up @@ -567,10 +567,10 @@ PrefabInstance:
- target: {fileID: 9144045080803666705, guid: 6906f74934047d24e9a47bbdd1afb57a,
type: 3}
propertyPath: m_Text
value: '<color=#B7B7B8><b>Trigger</b></color>
value: '<color=#B7B7B8><b>Bumper</b></color>
If tracking was not
set to enabled in the inspector settings, holding the trigger will toggle
If Always On was not
set to enabled in the inspector settings, holding the bumper will toggle
the tracker to be enabled.'
objectReference: {fileID: 0}
- target: {fileID: 9144045080852108117, guid: 6906f74934047d24e9a47bbdd1afb57a,
Expand Down Expand Up @@ -2722,12 +2722,6 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 907428589}
m_CullTransparentMesh: 0
--- !u!1 &920891312 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 5589497132891496769, guid: fe799b2d0a84dfe43b001b56276fd2fb,
type: 3}
m_PrefabInstance: {fileID: 957753390}
m_PrefabAsset: {fileID: 0}
--- !u!1 &957632325
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -3785,16 +3779,15 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: b2c42b3ea8c3b2f41add049147d57601, type: 3}
m_Name:
m_EditorClassIdentifier:
AlwaysOn: 0
statusText: {fileID: 80860511}
markerVisualPrefab: {fileID: 1901461232108414532, guid: f442d62da6611e44cb6847b0cfe52aa1,
type: 3}
markersRoot: {fileID: 920891312}
removeMarkersUsingTimeStamps: 0
markerTrackerTimeout: 0.5
MarkerTypes: -1
ArucoDicitonary: 0
ArucoMarkerSize: 0.1
ArucoTrackingCamera: 1
QRCodeSize: 0.1
TrackerProfile: 0
EnableMarkerScanning: 1
Expand Down
45 changes: 16 additions & 29 deletions Assets/MagicLeap/Examples/Scripts/AudioCaptureExample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ [SerializeField] [Tooltip("The text to display the recording status.")]

private bool hasPermission;

private MLAudioInput.MicCaptureType micCaptureType = MLAudioInput.MicCaptureType.VoiceCapture;
private MLAudioInput.MicCaptureType micCaptureType = MLAudioInput.MicCaptureType.VoiceComm;
private MLAudioInput.BufferClip mlAudioBufferClip;
private MLAudioInput.StreamingClip mlAudioStreamingClip;

Expand Down Expand Up @@ -204,33 +204,22 @@ private void StartMicrophone()
}

playbackAudioSource.Stop();
switch (captureMode)
if (captureMode != CaptureMode.Realtime)
{
case CaptureMode.Realtime:
if (mlAudioStreamingClip == null)
{
mlAudioStreamingClip = new MLAudioInput.StreamingClip(micCaptureType, 3, MLAudioInput.GetSampleRate(micCaptureType));
playbackAudioSource.pitch = 1;
}

playbackAudioSource.clip = mlAudioStreamingClip.UnityAudioClip;
playbackAudioSource.loop = true;
playbackAudioSource.Play();
break;
case CaptureMode.Interactive:
CreateInteractiveAudioBuffer();
playbackAudioSource.pitch = 1;
playbackAudioSource.clip = null;
playbackAudioSource.loop = false;
break;
return;
}

if (mlAudioStreamingClip == null)
{
mlAudioStreamingClip = new MLAudioInput.StreamingClip(micCaptureType, 3, MLAudioInput.GetSampleRate(micCaptureType));
playbackAudioSource.pitch = 1;
}
}

private void CreateInteractiveAudioBuffer()
{
mlAudioBufferClip = new MLAudioInput.BufferClip(micCaptureType, AudioClipLengthSeconds, MLAudioInput.GetSampleRate(micCaptureType));
playbackAudioSource.clip = mlAudioStreamingClip.UnityAudioClip;
playbackAudioSource.loop = true;
playbackAudioSource.Play();
}

private void VisualizeRecording()
{
rmsVisualizerMaterial.color = isCapturingInteractiveAudio ? Color.green : Color.white;
Expand All @@ -257,9 +246,10 @@ private void VisualizePlayback()
private void StopCapture()
{
isCapturingInteractiveAudio = false;
currentRecordedAudioLength = 0;

mlAudioStreamingClip?.ClearBuffer();

mlAudioBufferClip?.Dispose();
mlAudioBufferClip = null;

Expand Down Expand Up @@ -295,10 +285,7 @@ private void BeginInteractiveCapture()
{
playbackAudioSource.Stop();
isCapturingInteractiveAudio = true;
if (mlAudioBufferClip == null)
{
CreateInteractiveAudioBuffer();
}
mlAudioBufferClip = new MLAudioInput.BufferClip(micCaptureType, AudioClipLengthSeconds, MLAudioInput.GetSampleRate(micCaptureType));
}

private void StopInteractiveCapture()
Expand Down
46 changes: 37 additions & 9 deletions Assets/MagicLeap/Examples/Scripts/CVCameraExample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ public class CVCameraExample : MonoBehaviour
private readonly MLPermissions.Callbacks permissionCallbacks = new MLPermissions.Callbacks();

private StringBuilder statusText = new();

private Coroutine enableCameraCoroutine;

/// <summary>
/// Using Awake so that Permissions is set before PermissionRequester Start.
/// </summary>
Expand All @@ -75,6 +76,8 @@ void Awake()
mlInputs = new MagicLeapInputs();
mlInputs.Enable();
controllerActions = new MagicLeapInputs.ControllerActions(mlInputs);

controllerActions.Bumper.performed += OnButtonDown;

isCapturing = false;

Expand All @@ -93,14 +96,13 @@ void OnDisable()
permissionCallbacks.OnPermissionGranted -= OnPermissionGranted;
permissionCallbacks.OnPermissionDenied -= OnPermissionDenied;
permissionCallbacks.OnPermissionDeniedAndDontAskAgain -= OnPermissionDenied;

controllerActions.Bumper.performed -= OnButtonDown;
mlInputs.Dispose();

if (colorCamera != null && isCameraConnected)
{
DisableMLCamera();
}
controllerActions.Bumper.performed -= OnButtonDown;
mlInputs.Dispose();

}

/// <summary>
Expand All @@ -123,6 +125,10 @@ private void UpdateStatusText()
{
statusText.AppendLine($"\nStream width: {selectedCapability.Width} \nStream height{selectedCapability.Height}");
}
else
{
statusText.AppendLine("Camera Disconnected");
}
if (!string.IsNullOrEmpty(poseText))
{
statusText.AppendLine(poseText);
Expand All @@ -136,6 +142,25 @@ private void UpdateStatusText()
_statusText.text = statusText.ToString();
}

private void CheckAndStopPreviousCoroutine()
{
if (enableCameraCoroutine == null) return;
StopCoroutine(enableCameraCoroutine);
enableCameraCoroutine = null;
}

private void OnApplicationPause(bool pauseStatus)
{
if (pauseStatus)
{
colorCamera.OnRawVideoFrameAvailable -= OnCaptureRawVideoFrameAvailable;
}
else
{
colorCamera.OnRawVideoFrameAvailable += OnCaptureRawVideoFrameAvailable;
}
}

/// <summary>
/// Captures a still image using the device's camera and returns
/// the data path where it is saved.
Expand Down Expand Up @@ -173,7 +198,7 @@ private void StopVideoCapture()
colorCamera.CaptureVideoStop();
cameraCaptureVisualizer.HideRenderer();
}

isCapturing = false;
}

Expand Down Expand Up @@ -226,7 +251,6 @@ private IEnumerator EnableMLCamera()

Debug.Log("Camera device received stream caps");
colorCamera.OnRawVideoFrameAvailable += OnCaptureRawVideoFrameAvailable;
controllerActions.Bumper.performed += OnButtonDown;
}
}

Expand All @@ -253,7 +277,7 @@ private void DisableMLCamera()
/// <param name="button">The button that is being pressed.</param>
private void OnButtonDown(InputAction.CallbackContext obj)
{
if (colorCamera.IsPaused)
if (colorCamera is { IsPaused: true } || !isCameraConnected)
{
return;
}
Expand All @@ -274,6 +298,10 @@ private void OnButtonDown(InputAction.CallbackContext obj)
/// <param name="imageData">The raw data of the image.</param>
private void OnCaptureRawVideoFrameAvailable(MLCamera.CameraOutput capturedFrame, MLCamera.ResultExtras resultExtras, MLCamera.Metadata metadataHandle)
{
if (colorCamera is { IsPaused: true })
{
return;
}
cameraCaptureVisualizer.OnCaptureDataReceived(resultExtras, capturedFrame);

if (MLCVCamera.GetFramePose(resultExtras.VCamTimestamp, out Matrix4x4 cameraTransform).IsOk)
Expand All @@ -293,7 +321,7 @@ private void OnPermissionDenied(string permission)

private void OnPermissionGranted(string permission)
{
StartCoroutine(EnableMLCamera());
enableCameraCoroutine = StartCoroutine(EnableMLCamera());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
// ---------------------------------------------------------------------
// %BANNER_END%

// Disabling MLMedia deprecated warning for the internal project
#pragma warning disable 618

using System;
using System.Collections;
using System.Collections.Generic;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public class MarkerTrackingExampleEditor : Editor
SerializedProperty QRCodeSize;
SerializedProperty ArucoMarkerSize;
SerializedProperty ArucoDicitonary;
SerializedProperty ArucoTrackingCamera;
SerializedProperty TrackerProfile;
SerializedProperty EnableMarkerScanning;
SerializedProperty FPSHint;
Expand All @@ -41,7 +40,6 @@ private void OnEnable()
QRCodeSize = serializedObject.FindProperty("QRCodeSize");
ArucoMarkerSize = serializedObject.FindProperty("ArucoMarkerSize");
ArucoDicitonary = serializedObject.FindProperty("ArucoDicitonary");
ArucoTrackingCamera = serializedObject.FindProperty("ArucoTrackingCamera");
TrackerProfile = serializedObject.FindProperty("TrackerProfile");
EnableMarkerScanning = serializedObject.FindProperty("EnableMarkerScanning");
FPSHint = serializedObject.FindProperty("FPSHint");
Expand Down Expand Up @@ -77,7 +75,6 @@ public override void OnInspectorGUI()
{
EditorGUILayout.PropertyField(ArucoMarkerSize);
EditorGUILayout.PropertyField(ArucoDicitonary);
EditorGUILayout.PropertyField(ArucoTrackingCamera);
}

EditorGUILayout.PropertyField(TrackerProfile);
Expand Down
Loading

0 comments on commit ea709a1

Please sign in to comment.