none
Body angle calculation with 1.8 Kinect SDK RRS feed

  • Question

  • Hello,

    we are trying to determine the angle of a user's body using the latest kinect SDK but our results are wrong (negative angles etc...).

    Our current code is :

    double angle_rad;
    
                                if ((s.Joints[JointType.ShoulderLeft].TrackingState == JointTrackingState.Inferred) ||                            ((s.Joints[JointType.ShoulderRight].TrackingState == JointTrackingState.Inferred))) {
                                        angle_rad = -(float)Math.Atan2(s.Joints[JointType.HipLeft].Position.Z - s.Joints[JointType.HipRight].Position.Z,
                                        s.Joints[JointType.HipRight].Position.X - s.Joints[JointType.HipLeft].Position.X);
                                    }
                                else {
                                    angle_rad = -(float)Math.Atan2(s.Joints[JointType.ShoulderLeft].Position.Z - s.Joints[JointType.ShoulderRight].Position.Z,
                                        s.Joints[JointType.ShoulderRight].Position.X - s.Joints[JointType.ShoulderLeft].Position.X);
                                }
                                double angle_deg = angle_rad * 180 / Math.PI;

    Where is the problem ?

    Thanks in advance,

    Best regards

    Benjamin.

    Friday, May 30, 2014 8:24 AM

All replies

  • If you are subtracting positions to calculate a vector to then calculate and angle, then if would be an order of operation issue. The points you pick and the order matter. If you are trying to determine the angle between the shoulder and the arm, you need to generate the vectors going into the joint position you are interested in:

    V1: shoulder point - neck point

    v2: elbow point - shoulder point

    angle = dot(v1, v2) - http://en.wikipedia.org/wiki/Dot_product


    Carmine Sirignano - MSFT

    Friday, May 30, 2014 7:44 PM