문제

I would like to write joint positions to a txt file. I have a method to get the X,Y,Z positions of one joint.

  public void positions(Skeleton skeleton)
    {
        // get the joint
        Joint rightHand = skeleton.Joints[JointType.HandRight];

        // get the individual points of the right hand
        double rightX = rightHand.Position.X;
        double rightY = rightHand.Position.Y;
        double rightZ = rightHand.Position.Z;     
    }

and I have my click method

  private void stoji_Click(object sender, RoutedEventArgs e)
    {

           File.AppendAllText(@"E:\skuska.txt", rightX + ", " + rightY + ", " +rightZ + Environment.NewLine);

    }

But obviously the rightX, rightY and rightZ cannot be seen from onclick method. And if I add the code from positions method to onclick method, it does not recognize "skeleton".

Thank you

도움이 되었습니까?

해결책

Make rightX, rightY, rightZ instance variables of your class.

public class MyKinect
{
   private double rightX;
   private double rightY;
   private double rightZ;

   public void positions(Skeleton skeleton)
   {
      // get the joint
      Joint rightHand = skeleton.Joints[JointType.HandRight];

      // get the individual points of the right hand
      rightX = rightHand.Position.X;
      rightY = rightHand.Position.Y;
      rightZ = rightHand.Position.Z;     
   }

   private void stoji_Click(object sender, RoutedEventArgs e)
   {
      File.AppendAllText(@"E:\skuska.txt", rightX + ", " + rightY + ", " +rightZ + Environment.NewLine);
    }
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top