Question

I'm trying to create a .bvh file via kinect.

It means in need to get rotations of each bone of a skeleton. I need the rotations in Euler angles. I already tried many different approaches, but any of them gave me good result. Could anyone give me some advice what am I doing wrong?

Here is (I think) the main part of my code.

foreach (Skeleton skeleton in newSkeleton)
{
    if (skeleton.TrackingState != SkeletonTrackingState.Tracked)
        continue;
    int j = 0;                
    foreach (BoneOrientation orientation in skeleton.BoneOrientations)
    { 
        Matrix4 matrix = orientation.HierarchicalRotation.Matrix;

        double y = Math.Asin(matrix.M13);
        double x = Math.Atan2(-matrix.M23, matrix.M33);
        double z = Math.Atan2(-matrix.M12, matrix.M11);

        rotationMatrix[j, 0] = x * 180 / Math.PI;
        rotationMatrix[j, 1] = y * 180 / Math.PI;
        rotationMatrix[j, 2] = z * 180 / Math.PI;                   
        j++;
    }
}

My euler angles should be stored in the rotationMatrix array for further use (saving into bvh file). Here comes my problem... the rotations calculated this way doesn't make sense (I mean they have nothing to do with the position of me ahead of kinect) and they seems to be random.

Edit:

I would also need to explain some unclear topics about kinect. I tried to Google it, but didn't succeed.

  1. Does kinect skeleton have something like zero pose? I mean any pose where all bone rotations are zero. (e.g. T-pose and so on)

  2. What kind of standards does kinect use? I mean how does kinect store data into rotation matrices? I would like to know if the matrix is like

    [X1, Y1, Z1,

    X2, Y2, Z2,

    X3, Y3, Z3]

    or does it use some other order?

  3. About the marices.. Is it possible to calculate Euler angles from the matrix given by kinect in standard way? I mean some of algorithms mentioned in this paper?

    http://www.geometrictools.com/Documentation/EulerAngles.pdf

Was it helpful?

Solution

OK, after some more time spend researching, i think i might be able to answer some of mine questions. If is anyone interested...

  1. i havent found any zero pose, but i created my own using some kind of calibration. I saved rotation matrices for my chosen zero pose (let's call these Mz), made these matrices trandposed (MzT) and I multiplied all the next matrices kinect gave me (let's call these Mr). It means I calculated matrices for further use this way: M = MzT x Mr.
  2. I used the conversion from link in 3. question for Rxyz order and all worked well, it means the rotation matrices given by kinect probably have the order given in the question. This should be answer to the third question as well.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top