查找 Kinect 的偏移量(坐标之间的差异)

本文关键字:之间 Kinect 偏移量 查找 坐标 | 更新日期: 2023-09-27 18:31:39

我正在做一个 kinect 项目。我试图找到偏移量(关节坐标之间的差异)并使用TCP/IP通过网络发送。但是,我面临着访问关节先前值的问题。这些是我到目前为止的代码:

Joint right = skel.Joints[JointType.HandRight];
double right = right.Position.X;

/*        
I need an operation here to calculate the offset of right before sending it
Meaning, offset= right(current coordinate)-right(previous coordinate)
How can I do this in C# ?
I have tried this operation as mentioned below but it is printing all zeros although I moved (if move, previous - current coordinates shall not be zero)
*/
//---------------------------------------------------------------------------   
double offset = 0;
double[] of = new double[2];
  for (int i = 0; i < of.Length; i++)
 {
    if (i > 2)
   {
     break;
   }
     of[i] = right;
     offset = of[1] - of[0];                                  
  }
//---------------------------------------------------------------------------    
//convert the data to bytes before sending
byte[] rh = BitConverter.GetBytes(offset);
//sending the data to the server
client.Send(rh, rh.Length);

查找 Kinect 的偏移量(坐标之间的差异)

// make it global 
     double previousval=-1000;
     double currentVal=-1000;
then in your code
     Joint right = skel.Joints[JointType.HandRight];
     currentVal=right.Position.X;
     double offset = 0;
     if(prev==-1000)
        offset =  currentVal - currentVal;
     else
        offset = previousval - currentVal;  
     previousval=currentVal;