/// <summary> /// 创建左右手PHIZ /// </summary> /// <param name="body">Body.</param> /// <param name="left">Left.</param> /// <param name="right">Right.</param> public static void Create( Windows.Kinect.Body body, ref PHIZ left, ref PHIZ right ) { // if( body == null || left == null || right == null ) { Debug.Log( "Can not create PHIZ." ); return; } // Windows.Kinect.Joint jointShoulderLeft = body.Joints[Windows.Kinect.JointType.ShoulderLeft]; Windows.Kinect.Joint jointShoulderRight = body.Joints[Windows.Kinect.JointType.ShoulderRight]; Windows.Kinect.Joint jointElbowLeft = body.Joints[Windows.Kinect.JointType.ElbowLeft]; Windows.Kinect.Joint jointElbowRight = body.Joints[Windows.Kinect.JointType.ElbowRight]; Windows.Kinect.Joint jointHead = body.Joints[Windows.Kinect.JointType.Head]; Windows.Kinect.Joint jointSpineMid = body.Joints[Windows.Kinect.JointType.SpineMid]; // Vector3 vJointShoulderLeftPos = new Vector3( jointShoulderLeft.Position.X, jointShoulderLeft.Position.Y, jointShoulderLeft.Position.Z ); Vector3 vJointShoulderRightPos = new Vector3( jointShoulderRight.Position.X, jointShoulderRight.Position.Y, jointShoulderRight.Position.Z ); Vector3 vJointElbowLeftPos = new Vector3( jointElbowLeft.Position.X, jointElbowLeft.Position.Y, jointElbowLeft.Position.Z ); Vector3 vJointElbowRightPos = new Vector3( jointElbowRight.Position.X, jointElbowRight.Position.Y, jointElbowRight.Position.Z ); Vector3 vJointHeadPos = new Vector3( jointHead.Position.X, jointHead.Position.Y, jointHead.Position.Z ); Vector3 vJointSpineMidPos = new Vector3( jointSpineMid.Position.X, jointSpineMid.Position.Y, jointSpineMid.Position.Z ); //Vector3 vJointSpineShoudler = GetVector3FromJoint(jointSpineShoulder); // float fUpperArmLeftLen = (vJointShoulderLeftPos - vJointElbowLeftPos).magnitude; float fUpperArmRightLen = (vJointShoulderRightPos - vJointElbowRightPos).magnitude; float fShouldersLen = (vJointShoulderLeftPos - vJointShoulderRightPos).magnitude; //float fHeadToElbowLeftLen = (vJointHeadPos - vJointElbowLeftPos).magnitude; //float fHeadToElbowRightLen = (vJointHeadPos - vJointElbowRightPos).magnitude; float fHeadToSpineMidLen = (vJointHeadPos - vJointSpineMidPos).magnitude; //Debug.Log( "fUpperArmLeftLen:"+fUpperArmLeftLen+" fUpperArmRightLen:"+fUpperArmRightLen+" fShouldersLen:"+fShouldersLen+ // " fHeadToElbowLeftLen"+fHeadToElbowLeftLen+" fHeadToElbowRightLen:"+fHeadToElbowRightLen +" fHeadToSpineMidLen:"+fHeadToSpineMidLen); float fAverageArmLen = ( fUpperArmLeftLen + fUpperArmRightLen ) * 0.5f; float fHalfArmLen = fAverageArmLen * 0.5f; left.bias = (new Vector3(-1f,-1f,0f)).normalized * fHalfArmLen + new Vector3(0,0,-(fAverageArmLen + 0.5f)); right.bias = (new Vector3(1f,-1f,0f)).normalized * fHalfArmLen + new Vector3(0,0,-(fAverageArmLen + 0.5f)); left.width = fShouldersLen*1.5f; left.height = fHeadToSpineMidLen; right.width = fShouldersLen*1.5f; right.height = fHeadToSpineMidLen; }
/// <summary> /// 创建左右手PHIZ /// </summary> /// <param name="body">Body.</param> /// <param name="left">Left.</param> /// <param name="right">Right.</param> public static void Create( Windows.Kinect.CameraSpacePoint[] filteredJoints, ref PHIZ left, ref PHIZ right ) { // if( filteredJoints == null || left == null || right == null ) { Debug.Log( "Can not create PHIZ." ); return; } // Vector3 vJointShoulderLeftPos = Utils.GetVector3FromCameraSpacePoint( filteredJoints[(int)Windows.Kinect.JointType.ShoulderLeft] ); Vector3 vJointShoulderRightPos = Utils.GetVector3FromCameraSpacePoint( filteredJoints[(int)Windows.Kinect.JointType.ShoulderRight] ); Vector3 vJointElbowLeftPos = Utils.GetVector3FromCameraSpacePoint( filteredJoints[(int)Windows.Kinect.JointType.ElbowLeft] ); Vector3 vJointElbowRightPos = Utils.GetVector3FromCameraSpacePoint( filteredJoints[(int)Windows.Kinect.JointType.ElbowRight] ); Vector3 vJointHeadPos = Utils.GetVector3FromCameraSpacePoint( filteredJoints[(int)Windows.Kinect.JointType.Head] ); Vector3 vJointSpineMidPos = Utils.GetVector3FromCameraSpacePoint( filteredJoints[(int)Windows.Kinect.JointType.SpineMid] ); // float fUpperArmLeftLen = (vJointShoulderLeftPos - vJointElbowLeftPos).magnitude; float fUpperArmRightLen = (vJointShoulderRightPos - vJointElbowRightPos).magnitude; float fShouldersLen = (vJointShoulderLeftPos - vJointShoulderRightPos).magnitude; //float fHeadToElbowLeftLen = (vJointHeadPos - vJointElbowLeftPos).magnitude; //float fHeadToElbowRightLen = (vJointHeadPos - vJointElbowRightPos).magnitude; float fHeadToSpineMidLen = (vJointHeadPos - vJointSpineMidPos).magnitude; //Debug.Log( "fUpperArmLeftLen:"+fUpperArmLeftLen+" fUpperArmRightLen:"+fUpperArmRightLen+" fShouldersLen:"+fShouldersLen+ // " fHeadToElbowLeftLen"+fHeadToElbowLeftLen+" fHeadToElbowRightLen:"+fHeadToElbowRightLen +" fHeadToSpineMidLen:"+fHeadToSpineMidLen); float fAverageArmLen = ( fUpperArmLeftLen + fUpperArmRightLen ) * 0.5f; float fHalfArmLen = fAverageArmLen * 0.5f; left.bias = (new Vector3(-1f,-1f,0f)).normalized * fHalfArmLen + new Vector3(0,0,-(fAverageArmLen + 0.5f)); right.bias = (new Vector3(1f,-1f,0f)).normalized * fHalfArmLen + new Vector3(0,0,-(fAverageArmLen + 0.5f)); left.width = fShouldersLen*1.5f; left.height = fHeadToSpineMidLen; right.width = fShouldersLen*1.5f; right.height = fHeadToSpineMidLen; }