public void OnNewPointFrame(Astra.PointFrame pointFrame) { //TODO: I think this should guarantee that there is data, but should make sure if (pointFrame.Width == 0 || pointFrame.Height == 0) { return; } //This is default, but I would assume astra only calls "onNewFrame" once fram index has changed in the first place?? //if (_lastFrameIndex == pointFrame.FrameIndex) //{ // return; //} //_lastFrameIndex = depthFrame.FrameIndex; //print("Depth frame x: " + depthFrame.Width + "y: " + depthFrame.Height); //EnsureBuffers(depthFrame.Width, depthFrame.Height); //depthFrame.CopyData(ref _depthFrameData); Astra.Vector3D[] pointData = new Astra.Vector3D[pointFrame.Width * pointFrame.Height]; //Vector3[] pointData = new Vector3; pointFrame.CopyData(ref pointData); dataToParticles(pointData); }
// astra vectors are in mm, convert to a good unity scale as this is too big public static Vector3 AstraVector3dToUnity(Astra.Vector3D astraVector, float scale = 0.01f) => new Vector3( astraVector.X, astraVector.Y, astraVector.Z) * 0.01f;
private Vector3 V3(Astra.Joint joint1, Astra.Joint joint2) { Astra.Vector3D value1 = joint1.WorldPosition; Astra.Vector3D value2 = joint2.WorldPosition; return(new Vector3(value2.X - value1.X, value2.Y - value1.Y, value2.Z - value1.Z)); }
private Vector3 V3(Astra.Vector3D value) { return(new Vector3(value.X, value.Y, value.Z)); }