使用1.8 Kinect SDK计算体角 [英] Body angle calculation with 1.8 Kinect SDK

查看:63
本文介绍了使用1.8 Kinect SDK计算体角的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


我们正在尝试使用最新的kinect SDK确定用户身体的角度,但我们的结果是错误的(负角度等......)。


我们当前的代码是:

 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;

问题出在哪里?


提前致谢,


祝你好运


本杰明。

解决方案

如果要减去位置来计算向量然后计算和角度,那么将是一个操作顺序问题。您选择的点和订单很重要。如果你想确定肩膀和手臂之间的角度,你需要
来生成进入你感兴趣的关节位置的向量:


V1:肩点 - 颈部点


v2:肘点 - 肩点


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


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.

解决方案

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


这篇关于使用1.8 Kinect SDK计算体角的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆