///
///根据人体各种姿态的生理数据判断姿态///通过关节之间角度,关节之间的相关位置判断姿态///
/// 骨架数据
private voidProcessPosePerForming2(Skeleton sk)
{string mess = "";//T型姿态//double angelLeft = GetJointAngle(sk.Joints[JointType.ElbowLeft],sk.Joints[JointType.ShoulderLeft]);//double angelRight = GetJointAngle(sk.Joints[JointType.ElbowRight],sk.Joints[JointType.ShoulderRight]);
#region 获取数据
double angelLeft =GetJointAngle(sk.Joints[JointType.ShoulderLeft], sk.Joints[JointType.ElbowLeft], sk.Joints[JointType.WristLeft]);double angelRight =GetJointAngle(sk.Joints[JointType.ShoulderRight], sk.Joints[JointType.ElbowRight], sk.Joints[JointType.WristRight]);//胸关节空间位置
Vector4 shoulderCenter =GetJointVector4(sk.Joints[JointType.ShoulderCenter]);
Vector4 handLeft=GetJointVector4(sk.Joints[JointType.HandLeft]);
Vector4 handRight=GetJointVector4(sk.Joints[JointType.HandRight]);
Vector4 spine=GetJointVector4(sk.Joints[JointType.Spine]);double leftCentZ = Math.Round((shoulderCenter.Z - handLeft.Z), 2);double rightCenterZ = Math.Round((shoulderCenter.Z - handRight.Z), 2);double leftAndRightX = Math.Round(Math.Abs((handRight.X - handLeft.X)), 2);double leftAndRightY = Math.Round(Math.Abs((handRight.Y - handLeft.Y)), 2);#endregion
#region 姿势判断
//T型姿势
if (leftAndRightX >= 750 && leftAndRightY <= 10 && isOK == false)
{
mess= "T型姿势";
KinectTimer.Start();
isKinectControl= true;
(minWindow.FindName("gridMainMenu") as Grid).Visibility =Visibility.Collapsed;
(minWindow.FindName("gridPose") as Grid).Visibility =Visibility.Visible;
(minWindow.FindName("gridTuch") as Grid).Visibility =Visibility.Collapsed;if ((this.minWindow as MainMenu).mainWindow != null)
{
(this.minWindow as MainMenu).mainWindow.VRPControl.ExecuteVrpScript("执行内部函数,funReset");
}
}else
//左手举起,右手放下
if (leftAndRightY > 200 && handLeft.Y < handRight.Y &&isOK)
{
mess= "左手举起,右手放下";
(minWindow.FindName("gridMainMenu") as Grid).Visibility =Visibility.Collapsed;
(minWindow.FindName("gridPose") as Grid).Visibility =Visibility.Collapsed;
(minWindow.FindName("gridTuch") as Grid).Visibility =Visibility.Visible;
}else
//右手举起,左手放下
if (leftAndRightY > 200 && handLeft.Y > handRight.Y &&isOK)
{
mess= "右手举起,左手放下";
}else
//双手交叉
if ((handRight.X - handLeft.X) < 0 && handLeft.Y < 150 && handRight.Y < 150 && isOK) //handLeft.Y
{
mess= "双手交叉";
KinectTimer.Stop();
isKinectControl= false;
(minWindow.FindName("gridMainMenu") as Grid).Visibility =Visibility.Visible;
(minWindow.FindName("gridPose") as Grid).Visibility =Visibility.Collapsed;
(minWindow.FindName("gridTuch") as Grid).Visibility =Visibility.Collapsed;if ((this.minWindow as MainMenu).mainWindow != null)
{
(this.minWindow as MainMenu).mainWindow.VRPControl.ExecuteVrpScript("执行内部函数,funReset");
(this.minWindow as MainMenu).mainWindow.VRPControl.ExecuteVrpScript(&