none
Calculating angles RRS feed

  • Question

  • Im trying to calculate the angle of the elbow joint using the kinect sdk.

    I use the following:

    new vec1 = elbowPosition - wristPosition;
    new vec2 = elbowPosition - shoulderPosition;
    
    double angle = Vector3D.AngleBetween(newVec1, newVec2)
    

     


    If i stand directly facing the camera the angle produiced by this is very accurate.

    However, if I keep my elbow at the same angle but rotate my body the angle grows when moving towards the camera and decreases when moving away.

    Does anyone have any idea as to why this would happen?

    Thanks, Chris


    Tuesday, July 12, 2011 9:42 AM

Answers

  • Draw the joints over top of the vidio image. The skeleton tracking is using, basically, image recognition to identify joint positions. Likely it's varying in where it thinks your shoulder is since that's rather hard to seperate out. That would be physically on your body, not relative to the camera. So likely if you plot the joint positions overtop of the video you'll see the elbow is staying on the elbow, the wrist on the wrist and the shoulder is moving around.

    A simplier solution would be check the magnitude of those two vectors. The mangitude of the vectors doesn't impact the angle calculation, but it implies the skeleton tracking is changing where on the body the joints are located. Likely the tracked position of the shoulder relative to the elbow is moving around.

    Tuesday, July 12, 2011 7:26 PM
  • They seem to have hosed up the transform. If OD, OX and OY are the original depth and pixel coordinates and SX, SY and SZ are the transformed skeleton coordinates then OD = SZ * 8000, OX = (((SX / SZ) / 0.56016) + 1) / 2 and OY = 1 - ((SY / SZ) / 0.42012) + 1) / 2. There should be some trig involved in there somewhere. As it is you need to do your own conversion.


    • Proposed as answer by LilBudyWizer Wednesday, July 13, 2011 3:43 AM
    • Marked as answer by chris_golby Wednesday, July 13, 2011 10:16 AM
    Wednesday, July 13, 2011 3:42 AM

All replies

  • This is because the angle changes relative to the camera. It is like the distance between the goal post in a game of football if you are directly in front, the distance between the posts is large but if you are at the side line the distance between the post looks smaller.

    Tuesday, July 12, 2011 12:20 PM
  • Are you sure of that ? He is dealing with 3D vectors, not projected vectors, so it shoudl work, right ?
    Tuesday, July 12, 2011 12:25 PM
  • Thats what I believe, it shouldnt change with a z coordinate present. Plus, if that was the case, surely the angle would get smaller as i rotated towards the camera.
    Tuesday, July 12, 2011 12:40 PM
  • yeah it sounds like it is just getting the Z/Y angle...

    I don't use C# or the pre made angle funcs, so I'm not sure..

     

    try it with the math written out..  

    Tuesday, July 12, 2011 5:33 PM
  • Draw the joints over top of the vidio image. The skeleton tracking is using, basically, image recognition to identify joint positions. Likely it's varying in where it thinks your shoulder is since that's rather hard to seperate out. That would be physically on your body, not relative to the camera. So likely if you plot the joint positions overtop of the video you'll see the elbow is staying on the elbow, the wrist on the wrist and the shoulder is moving around.

    A simplier solution would be check the magnitude of those two vectors. The mangitude of the vectors doesn't impact the angle calculation, but it implies the skeleton tracking is changing where on the body the joints are located. Likely the tracked position of the shoulder relative to the elbow is moving around.

    Tuesday, July 12, 2011 7:26 PM
  • They seem to have hosed up the transform. If OD, OX and OY are the original depth and pixel coordinates and SX, SY and SZ are the transformed skeleton coordinates then OD = SZ * 8000, OX = (((SX / SZ) / 0.56016) + 1) / 2 and OY = 1 - ((SY / SZ) / 0.42012) + 1) / 2. There should be some trig involved in there somewhere. As it is you need to do your own conversion.


    • Proposed as answer by LilBudyWizer Wednesday, July 13, 2011 3:43 AM
    • Marked as answer by chris_golby Wednesday, July 13, 2011 10:16 AM
    Wednesday, July 13, 2011 3:42 AM