Browse Source

Track bumper for person

Nick Steyer 1 year ago
parent
commit
157b7d1315

+ 8 - 5
Assets/ZED/Examples/Object Detection/Scripts/ZED3DObjectVisualizer.cs

@@ -175,27 +175,28 @@ public class ZED3DObjectVisualizer : MonoBehaviour
         List<int> activeids = liveBBoxes.Keys.ToList();
 
         List<DetectedObject> newobjects = dframe.GetFilteredObjectList(showONTracked, showSEARCHINGTracked, showOFFTracked);
-        var dobj = newobjects.FirstOrDefault();
-        if (dobj != null)
+
+        int count = 1;
+        foreach (var dobj in newobjects.Take(2))
         {
+            GameObject bump = GameObject.Find($"Bump{count}");
             Bounds objbounds = dobj.Get3DWorldBounds();
             //Make sure the object is big enough to count. We filter out very small boxes.
             if (objbounds.size.x < minimumWidthToDisplay || objbounds.size == Vector3.zero) { }
             {
-
                 //Remove the ID from the list we'll use to clear no-longer-visible boxes.
                 if (activeids.Contains(dobj.id)) activeids.Remove(dobj.id);
 
                 //Get the box and update its distance value.
                 GameObject bbox = GetBBoxForObject(dobj);
-                GameObject ball = GameObject.Find("Sphere");
+
                 //Move the box into position.
                 Vector3 obj_position = dobj.Get3DWorldPosition();
 
                 if (!ZEDSupportFunctions.IsVector3NaN(obj_position))
                 {
                     bbox.transform.position = obj_position;
-                    ball.transform.position = obj_position;
+                    bump.transform.position = obj_position;
                     if (floorBBoxPosition)
                     {
                         bbox.transform.position = new Vector3(bbox.transform.position.x, 0, bbox.transform.position.z);
@@ -244,6 +245,8 @@ public class ZED3DObjectVisualizer : MonoBehaviour
             {
                 ReturnBoxToPool(id, liveBBoxes[id]);
             }
+
+            count++;
         }
     }