Items with no label
3338 Discussions

Unity Wrapper C# - Get position of highest or lowest points of Depth

NSand5
Beginner
1,376 Views

Camera Model D415

Firmware Version 05.11.06.250

Operating System & Version Windows 10

Platform PC

SDK Version2.latest

Language Unity c#

I am trying to get the in scene location (x,y,z) for the highest point/points from the depth points. My immediate goal is to assign a simple 3D object (cube) to the highest points and have them move as the as the position of the highest point changes realtime -> ie the Vector3 transform

 

I was planning on using something like this - which obviously wont work since the shader forces a vertex count. IS there a way to get the position of the points? or assign a cube to the highest point in the depth array?

using System.Collections; using System.Collections.Generic; using UnityEngine;   public class Zenith : MonoBehaviour { public MeshFilter RTMesh; public GameObject cube;   private Vector3[] verts; Vector3 TopVertex; // Start is called before the first frame update void Start() { }   // Update is called once per frame void Update() { verts = RTMesh.sharedMesh.vertices; TopVertex = new Vector3(0, float.NegativeInfinity, 0); for (int i = 0; i < verts.Length; i++) { Vector3 vect = transform.TransformPoint(verts[i]); if (vect.y > TopVertex.y) { TopVertex = vect; cube.transform.position = TopVertex; } } }   }

 

0 Kudos
1 Solution
MartyG
Honored Contributor III
1,120 Views

The ​RealSense GitHub, where you have also posted this question, is the best place to get advice on this subject. Good luck!

View solution in original post

0 Kudos
2 Replies
MartyG
Honored Contributor III
1,121 Views

The ​RealSense GitHub, where you have also posted this question, is the best place to get advice on this subject. Good luck!

0 Kudos
NSand5
Beginner
1,120 Views

Thank you MartyG. Already done.

0 Kudos
Reply