/// <summary> /// Compares height between two joints /// </summary> /// <param name="kb">Kinect body</param> /// <param name="first">First kinect joint</param> /// <param name="second">Second Kinect joint</param> /// <returns>true if both joints are at least inferred and first joint Y > second joint Y, false otherwise (also returns false if one of those joints is not tracked)</returns> public static bool CompareHeight(this KinectBody kb, JointType first, JointType second) { Joint j1 = kb.Joints[first]; Joint j2 = kb.Joints[second]; return(j1.IsAtLeastInferred() && j2.IsAtLeastInferred() && j1.Position.Y > j2.Position.Y); }
public void TestUploadEmpty() { using (BodyJointOrientationBuffer buffer = new BodyJointOrientationBuffer(device)) { KinectBody[] empty = new KinectBody[0]; buffer.Copy(device.ImmediateContext, empty); } }
/// <summary> /// Constructor /// </summary> /// <param name="body">Kinect body</param> /// <param name="handType">Hand type</param> /// <param name="previousHandState">Previous hand state</param> public KinectHandStateEventArgs(KinectBody body, HandType handType, HandState previousHandState) { if (body == null) throw new ArgumentNullException("body"); this.body = body; this.handType = handType; this.previousHandState = previousHandState; }
public static KinectJointTable GetJointTable(this KinectBody body) { Dictionary <JointType, Vector3> joints = new Dictionary <JointType, Vector3>(); foreach (var kvp in body.Joints) { CameraSpacePoint csp = kvp.Value.Position; joints.Add(kvp.Key, new Vector3(csp.X, csp.Y, csp.Z)); } return(new KinectJointTable(body.TrackingId, joints)); }
/// <summary> /// Constructor /// </summary> /// <param name="body">Kinect body</param> /// <param name="handType">Hand type</param> /// <param name="previousHandState">Previous hand state</param> public KinectHandStateEventArgs(KinectBody body, HandType handType, HandState previousHandState) { if (body == null) { throw new ArgumentNullException("body"); } this.body = body; this.handType = handType; this.previousHandState = previousHandState; }
/// <summary> /// Constructor /// </summary> /// <param name="body">Kinect body</param> /// <param name="coordinateMapper">Coordinate mapper</param> public ColorSpaceKinectJoints(KinectBody body, CoordinateMapper coordinateMapper) { if (body == null) throw new ArgumentNullException("body"); if (coordinateMapper == null) throw new ArgumentNullException("coordinateMapper"); this.jointPositions = new Dictionary<JointType,ColorSpacePoint>(); foreach (Joint joint in body.Joints.Values) { this.jointPositions.Add(joint.JointType, coordinateMapper.MapCameraPointToColorSpace(joint.Position)); } }
/// <summary> /// Constructor /// </summary> /// <param name="body">Kinect body</param> /// <param name="coordinateMapper">Coordinate mapper</param> public ColorSpaceKinectJoints(KinectBody body, CoordinateMapper coordinateMapper) { if (body == null) { throw new ArgumentNullException("body"); } if (coordinateMapper == null) { throw new ArgumentNullException("coordinateMapper"); } this.jointPositions = new Dictionary <JointType, ColorSpacePoint>(); foreach (Joint joint in body.Joints.Values) { this.jointPositions.Add(joint.JointType, coordinateMapper.MapCameraPointToColorSpace(joint.Position)); } }
/// <summary> /// Checks if both hands are below hips /// </summary> /// <param name="kb">kinect body</param> /// <returns>True if both hands are below hips, false otherwise</returns> public static bool BothHandsBelowHip(this KinectBody kb) { return(kb.CompareHeight(JointType.HipRight, JointType.HandRight) && kb.CompareHeight(JointType.HipLeft, JointType.HandLeft)); }
/// <summary> /// Checks if both left and right hand are raised (we consider raised as "above head") /// </summary> /// <param name="kb">Kinect body to check</param> /// <returns>true if raised, false otherwise</returns> public static bool BothHandsRaised(this KinectBody kb) { return(kb.LeftHandRaised() && kb.RightHandRaised()); }
/// <summary> /// Checks if rights hand is raised (we consider raised as "above head") /// </summary> /// <param name="kb">Kinect body to check</param> /// <returns>true if raised, false otherwise</returns> public static bool RightHandRaised(this KinectBody kb) { return(kb.CompareHeight(JointType.HandRight, JointType.Head)); }
/// <summary> /// Constructor /// </summary> /// <param name="body">Relevant Kinect body</param> public KinectBodyEventArgs(KinectBody body) { this.body = body; }
/// <summary> /// Checks if a body tracking Id is contained into our list /// </summary> /// <param name="kb">Kinect body to check</param> /// <param name="bodyList">Body list to check</param> /// <returns>true is we found this body Id, false otherwise</returns> public static bool ContainsId(this KinectBody kb, IEnumerable <KinectBody> bodyList) { return(kb.FindById(bodyList) != null); }
/// <summary> /// Finds the relevant body from a list of bodies. Can be used to match a body id from a different frame /// </summary> /// <param name="kb">Kinect body to check</param> /// <param name="bodyList">List of body</param> /// <returns>Matched Kinect body (using id) if found, null otherwise</returns> public static KinectBody FindById(this KinectBody kb, IEnumerable <KinectBody> bodyList) { return(bodyList.Where(body => body.TrackingId == kb.TrackingId).FirstOrDefault()); }