使用Kinect v1查找关节之间的角度时遇到问题

时间:2019-02-20 20:58:13

标签: c# kinect

我试图找到Kinect和关节之间的角度。我找到3个关节点之间的角度。但是,当关节之间的角度为180度时,结果是不正确的。我显示了180度的手,腕和肘关节。但是角度值在170到177之间。相同的情况来自肩膀中心,脊椎和臀部中心之间的相同角度。当我直立时,角度为180,但不是。

我用来查找角度的功能

public static double AngleBetweenJoints(Joint j1, Joint j2, Joint j3)
{
double Angulo = 0;
double shrhX = j1.Position.X - j2.Position.X;
double shrhY = j1.Position.Y - j2.Position.Y;
double shrhZ = j1.Position.Z - j2.Position.Z;
double hsl = vectorNorm(shrhX, shrhY, shrhZ);
double unrhX = j3.Position.X - j2.Position.X;
double unrhY = j3.Position.Y - j2.Position.Y;
double unrhZ =j3.Position.Z - j2.Position.Z;
double hul = vectorNorm(unrhX, unrhY, unrhZ);
double mhshu = shrhX * unrhX + shrhY * unrhY + shrhZ * unrhZ;
double x = mhshu / (hul * hsl);
if (x != Double.NaN) 
{
    if (-1 <= x && x <= 1)
    {
        double angleRad = Math.Acos(x);
        Angulo = angleRad *(180.0 / Math.PI);
    }
    else
        Angulo = 0;
}
else
    Angulo = 0;
return Angulo;
}
private static double vectorNorm(double x, double y, double z)
{
return Math.Sqrt(Math.Pow(x, 2) + Math.Pow(y, 2) + Math.Pow(z, 2));
}

角度45,90等。正确的结果来了。在哪里还能找到错误或如何找到关节之间的角度?

0 个答案:

没有答案