|
@@ -1,4 +1,5 @@
|
|
|
-using System.Collections;
|
|
|
+using System;
|
|
|
+using System.Collections;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
using UnityEngine;
|
|
@@ -18,8 +19,10 @@ public class ZED3DObjectVisualizer : MonoBehaviour
|
|
|
/// If you want to visualize detections from multiple ZEDs at once you will need multiple ZED3DObjectVisualizer commponents in the scene.
|
|
|
/// </summary>
|
|
|
[Tooltip("The scene's ZEDManager.\r\n" +
|
|
|
- "If you want to visualize detections from multiple ZEDs at once you will need multiple ZED3DObjectVisualizer commponents in the scene. ")]
|
|
|
- public ZEDManager zedManager;
|
|
|
+ "If you want to visualize detections from multiple ZEDs at once you will need multiple ZED3DObjectVisualizer commponents in the scene. ")]
|
|
|
+ public IZEDManager ZedManager => zedManagerLazy.Value;
|
|
|
+
|
|
|
+ public Lazy<IZEDManager> zedManagerLazy = new(FindObjectOfType<ZEDManager>);
|
|
|
|
|
|
/// <summary>
|
|
|
/// If true, the ZED Object Detection manual will be started as soon as the ZED is initiated.
|
|
@@ -139,15 +142,10 @@ public class ZED3DObjectVisualizer : MonoBehaviour
|
|
|
// Use this for initialization
|
|
|
void Start()
|
|
|
{
|
|
|
- if (!zedManager)
|
|
|
- {
|
|
|
- zedManager = FindObjectOfType<ZEDManager>();
|
|
|
- }
|
|
|
-
|
|
|
- zedManager.OnObjectDetection += Visualize3DBoundingBoxes;
|
|
|
- zedManager.OnZEDReady += OnZEDReady;
|
|
|
+ ZedManager.OnObjectDetection += Visualize3DBoundingBoxes;
|
|
|
+ ZedManager.OnZEDReady += OnZEDReady;
|
|
|
|
|
|
- if (zedManager.estimateInitialPosition == false && transformBoxToTouchFloor == true)
|
|
|
+ if (ZedManager.EstimateInitialPosition == false && transformBoxToTouchFloor == true)
|
|
|
{
|
|
|
Debug.Log("Estimate initial position is set to false. Then, transformBoxToTouchFloor is disable.");
|
|
|
transformBoxToTouchFloor = false;
|
|
@@ -156,9 +154,9 @@ public class ZED3DObjectVisualizer : MonoBehaviour
|
|
|
|
|
|
private void OnZEDReady()
|
|
|
{
|
|
|
- if (startObjectDetectionAutomatically && !zedManager.IsObjectDetectionRunning)
|
|
|
+ if (startObjectDetectionAutomatically && !ZedManager.IsObjectDetectionRunning)
|
|
|
{
|
|
|
- zedManager.StartObjectDetection();
|
|
|
+ ZedManager.StartObjectDetection();
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -302,7 +300,7 @@ public class ZED3DObjectVisualizer : MonoBehaviour
|
|
|
if (boxhandler)
|
|
|
{
|
|
|
boxhandler.SetColor(col);
|
|
|
- if (zedManager.objectDetectionModel == sl.DETECTION_MODEL.CUSTOM_BOX_OBJECTS)
|
|
|
+ if (ZedManager.ObjectDetectionModel == sl.DETECTION_MODEL.CUSTOM_BOX_OBJECTS)
|
|
|
{
|
|
|
//boxhandler.SetID(dobj.rawObjectData.rawLabel.ToString());
|
|
|
boxhandler.SetID(dobj.id.ToString());
|
|
@@ -388,10 +386,10 @@ public class ZED3DObjectVisualizer : MonoBehaviour
|
|
|
|
|
|
private void OnDestroy()
|
|
|
{
|
|
|
- if (zedManager)
|
|
|
+ if (ZedManager != null)
|
|
|
{
|
|
|
- zedManager.OnObjectDetection -= Visualize3DBoundingBoxes;
|
|
|
- zedManager.OnZEDReady -= OnZEDReady;
|
|
|
+ ZedManager.OnObjectDetection -= Visualize3DBoundingBoxes;
|
|
|
+ ZedManager.OnZEDReady -= OnZEDReady;
|
|
|
}
|
|
|
}
|
|
|
|