protected internal override bool TestPosture(Microsoft.Kinect.Skeleton s) { /* * var handRight = s.Joints[Microsoft.Kinect.JointType.HandRight]; * var shoulderCenter = s.Joints[Microsoft.Kinect.JointType.ShoulderCenter]; * var shoulderLeft = s.Joints[Microsoft.Kinect.JointType.ShoulderLeft]; * var shoulderRight = s.Joints[Microsoft.Kinect.JointType.ShoulderRight]; * if (handRight.TrackingState != Microsoft.Kinect.JointTrackingState.Tracked || shoulderCenter.TrackingState != Microsoft.Kinect.JointTrackingState.Tracked || shoulderLeft.TrackingState != Microsoft.Kinect.JointTrackingState.Tracked || shoulderRight.TrackingState != Microsoft.Kinect.JointTrackingState.Tracked || ) || return false; || ||var handRightPosition = s.Joints[Microsoft.Kinect.JointType.HandRight].Position; ||return handRightPosition.Y > s.Joints[Microsoft.Kinect.JointType.ShoulderCenter].Position.Y || //&& handRightPosition.X > s.Joints[Microsoft.Kinect.JointType.ShoulderLeft].Position.X || && handRightPosition.X > s.Joints[Microsoft.Kinect.JointType.Head].Position.X; */ var handRight = s.Joints[Microsoft.Kinect.JointType.HandRight]; var shoulderCenter = s.Joints[Microsoft.Kinect.JointType.ShoulderCenter]; if (handRight.TrackingState != Microsoft.Kinect.JointTrackingState.Tracked || shoulderCenter.TrackingState != Microsoft.Kinect.JointTrackingState.Tracked) { return(false); } var handRightPosition = handRight.Position; var shoulderCenterPosition = shoulderCenter.Position; System.Windows.Media.Media3D.Vector3D vector = new System.Windows.Media.Media3D.Vector3D(handRightPosition.X - shoulderCenterPosition.X, handRightPosition.Y - shoulderCenterPosition.Y, handRightPosition.Z - shoulderCenterPosition.Z); return(vector.Length < 0.3); }
private Vertex3 GetJointPosition(Microsoft.Kinect.Skeleton skeleton, JointType jointType) { Microsoft.Kinect.JointType kinectJointType = JointUtilities.TranslateJointType(jointType); Microsoft.Kinect.SkeletonPoint kinectPoint = skeleton.Joints[kinectJointType].Position; Vertex3 position = GetPosition(kinectPoint); return(position); }
private bool ShouldTrackJoint(Microsoft.Kinect.Skeleton skeleton, JointType joint, JointType[] connectedJoints) { // All the joints must betracked. There must be two connected joints. return(connectedJoints.Length == 2 && JointTrackingState(skeleton, joint) == Microsoft.Kinect.JointTrackingState.Tracked && JointTrackingState(skeleton, connectedJoints[0]) == Microsoft.Kinect.JointTrackingState.Tracked && JointTrackingState(skeleton, connectedJoints[1]) == Microsoft.Kinect.JointTrackingState.Tracked); }
private Vertex3[] GetJointPositions(Microsoft.Kinect.Skeleton skeleton, JointType[] jointTypes) { Vertex3[] jointPositions = new Vertex3[jointTypes.Length]; for (int index = 0; index < jointTypes.Length; index++) { jointPositions[index] = GetJointPosition(skeleton, jointTypes[index]); } return(jointPositions); }
public OrientationInfo GetJointInfo(KinectJoint joint, int?playerId = null) { if (this.thisKinectGesturePlugin == null) { return(null); } if (this.thisKinectGesturePlugin.gestureProcessor == null) { return(null); } if (this.thisKinectGesturePlugin.gestureProcessor.Skeletons == null) { return(null); } Microsoft.Kinect.Skeleton skeleton = null; if (playerId == null) { foreach (Microsoft.Kinect.Skeleton s in this.thisKinectGesturePlugin.gestureProcessor.Skeletons) { if (s.TrackingState != Microsoft.Kinect.SkeletonTrackingState.NotTracked) { skeleton = s; break; } } } else { foreach (Microsoft.Kinect.Skeleton s in this.thisKinectGesturePlugin.gestureProcessor.Skeletons) { if (s.TrackingId == playerId.Value) { skeleton = s; break; } } } if (skeleton != null) { Microsoft.Kinect.SkeletonPoint jointPos = this.thisKinectGesturePlugin.gestureProcessor.NormalizeJoint(skeleton.Joints[(Microsoft.Kinect.JointType)joint]); return(new OrientationInfo() { playerId = skeleton.TrackingId, tracked = (skeleton.Joints[(Microsoft.Kinect.JointType)joint].TrackingState != Microsoft.Kinect.JointTrackingState.NotTracked), X = jointPos.X, Y = jointPos.Y, Z = jointPos.Z, }); } else { return(null); } }
public OrientationInfo GetPlayerInfo(int?playerId = null) { if (this.thisKinectGesturePlugin == null) { return(null); } if (this.thisKinectGesturePlugin.gestureProcessor == null) { return(null); } if (this.thisKinectGesturePlugin.gestureProcessor.Skeletons == null) { return(null); } Microsoft.Kinect.Skeleton skeleton = null; if (playerId == null) { foreach (Microsoft.Kinect.Skeleton s in this.thisKinectGesturePlugin.gestureProcessor.Skeletons) { if (s.TrackingState != Microsoft.Kinect.SkeletonTrackingState.NotTracked) { skeleton = s; break; } } } else { foreach (Microsoft.Kinect.Skeleton s in this.thisKinectGesturePlugin.gestureProcessor.Skeletons) { if (s.TrackingId == playerId.Value) { skeleton = s; break; } } } if (skeleton != null) { return(new OrientationInfo() { playerId = skeleton.TrackingId, tracked = (skeleton.TrackingState != Microsoft.Kinect.SkeletonTrackingState.NotTracked), X = skeleton.Position.X, Y = skeleton.Position.Y, Z = skeleton.Position.Z, }); } else { return(null); } }
private void _HandleSkeletonFrameReady(object sender, Microsoft.Kinect.SkeletonFrameReadyEventArgs args) { // Capture Kinect data Microsoft.Kinect.Skeleton[] skeletons = new Microsoft.Kinect.Skeleton[0]; using (Microsoft.Kinect.SkeletonFrame kinect_frame = args.OpenSkeletonFrame()) { if (kinect_frame != null) { skeletons = new Microsoft.Kinect.Skeleton[kinect_frame.SkeletonArrayLength]; kinect_frame.CopySkeletonDataTo(skeletons); } } // Convert the Microsoft Skeleton format to Rhapsody skeletons SkeletonFrame frame = new SkeletonFrame(); foreach (Microsoft.Kinect.Skeleton kinect_skeleton in skeletons) { if (kinect_skeleton.TrackingState != Microsoft.Kinect.SkeletonTrackingState.Tracked) { continue; } //Console.WriteLine("Kinect found skeleton " + kinect_skeleton.TrackingId + " (" + kinect_skeleton.Position.X + ", " + kinect_skeleton.Position.Y + ")"); Skeleton skeleton = new Skeleton { TrackingState = TrackingState.Tracked }; foreach (Microsoft.Kinect.Joint kinect_joint in kinect_skeleton.Joints) { Microsoft.Kinect.SkeletonPoint kinect_point = kinect_joint.Position; skeleton.Joints.Add(JointTypeConverter.Convert(kinect_joint.JointType), new Joint(kinect_point.X, kinect_point.Y, kinect_point.Z)); } frame.Skeletons.Add(skeleton); } // Invoke each of the Listeners foreach (Delegate d in this.SkeletonFrameReady.GetInvocationList()) { d.DynamicInvoke(new object[] { sender, new SkeletonFrameReadyEventArgs { Frame = frame } }); } }
internal protected override bool TestPosture(Microsoft.Kinect.Skeleton s) { var handRight = s.Joints[Microsoft.Kinect.JointType.HandRight]; var hipLeft = s.Joints[Microsoft.Kinect.JointType.HipLeft]; if (handRight.TrackingState != Microsoft.Kinect.JointTrackingState.Tracked || hipLeft.TrackingState != Microsoft.Kinect.JointTrackingState.Tracked) { return(false); } var handRightPosition = handRight.Position; var hipLeftPosition = hipLeft.Position; System.Windows.Media.Media3D.Vector3D vector = new System.Windows.Media.Media3D.Vector3D(handRightPosition.X - hipLeftPosition.X, handRightPosition.Y - hipLeftPosition.Y, handRightPosition.Z - hipLeftPosition.Z); return(vector.Length < 0.2); }
public float GetRelationshipInfo(KinectJoint actor, KinectJointRelationship relation, string relative) { if (this.thisKinectGesturePlugin == null) { return(float.NaN); } if (this.thisKinectGesturePlugin.gestureProcessor == null) { return(float.NaN); } if (this.thisKinectGesturePlugin.gestureProcessor.Skeletons == null) { return(float.NaN); } Microsoft.Kinect.Skeleton skeleton = null; foreach (Microsoft.Kinect.Skeleton s in this.thisKinectGesturePlugin.gestureProcessor.Skeletons) { if (s.TrackingState != Microsoft.Kinect.SkeletonTrackingState.NotTracked) { skeleton = s; break; } } if (skeleton != null) { if (this.thisKinectGesturePlugin.gestureProcessor.Relationships.ContainsKey(skeleton.TrackingId)) { if (this.thisKinectGesturePlugin.gestureProcessor.Relationships[skeleton.TrackingId].ContainsKey((Microsoft.Kinect.JointType)actor)) { if (this.thisKinectGesturePlugin.gestureProcessor.Relationships[skeleton.TrackingId][(Microsoft.Kinect.JointType)actor].ContainsKey(relative)) { if (this.thisKinectGesturePlugin.gestureProcessor.Relationships[skeleton.TrackingId][(Microsoft.Kinect.JointType)actor][relative].ContainsKey((GestureParser.Relationship)relation)) { return(this.thisKinectGesturePlugin.gestureProcessor.Relationships[skeleton.TrackingId][(Microsoft.Kinect.JointType)actor][relative][(GestureParser.Relationship)relation]); } return(float.NaN); } return(float.NaN); } return(float.NaN); } return(float.NaN); } return(float.NaN); }
private void TrackSkeletonJoints(Microsoft.Kinect.Skeleton skeleton, DateTime timeStamp) { // Tracks the MovingJoints in the specified skeleton. foreach (JointType jointType in JointUtilities.MovingJoints) { // RBakerFlag -> Needs to be refactored. Need to fire event. JointType[] connectedJoints = JointUtilities.GetConnectedJoints(jointType); if (!ShouldTrackJoint(skeleton, jointType, connectedJoints)) { continue; } Vertex3 jointPosition = GetJointPosition(skeleton, jointType); Vertex3[] connectedJointPositions = GetJointPositions(skeleton, connectedJoints); Vector3 boneA = new Vector3(connectedJointPositions[0], jointPosition); Vector3 boneB = new Vector3(connectedJointPositions[1], jointPosition); double bendAngle = Vector3Functions.Angle(boneA, boneB); MovingJoint movingJoint = new MovingJoint(jointType, jointPosition, bendAngle); OnJointTrackingCaptured(movingJoint, timeStamp); } }
private Microsoft.Kinect.JointTrackingState JointTrackingState(Microsoft.Kinect.Skeleton skeleton, JointType jointType) { Microsoft.Kinect.JointType kinectJointType = JointUtilities.TranslateJointType(jointType); return(skeleton.Joints[kinectJointType].TrackingState); }