void kinectRuntime_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e) { if (recorder != null) { recorder.Record(e.SkeletonFrame); } if (e.SkeletonFrame.Skeletons.Where(s => s.TrackingState != SkeletonTrackingState.NotTracked).Count() == 0) { return; } ProcessFrame(e.SkeletonFrame); }
void SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e) { SkeletonFrame allSkeletons = e.SkeletonFrame; if (isRecorder) { recorder.Record(allSkeletons); } // Get the first tracked skeleton SkeletonData skeleton = (from s in allSkeletons.Skeletons where s.TrackingState == SkeletonTrackingState.Tracked select s).FirstOrDefault(); if (skeleton != null) { Vector3 skeletonPosition = new Vector3(skeleton.Position.X, skeleton.Position.Y, skeleton.Position.Z); barycenterHelper.Add(skeletonPosition, skeleton.TrackingID); // Set positions on our joints of interest Head = GetScaledPosition(skeleton.Joints[JointID.Head]); HandLeft = GetScaledPosition(skeleton.Joints[JointID.HandLeft]); HandRight = GetScaledPosition(skeleton.Joints[JointID.HandRight]); ShoulderCenter = GetScaledPosition(skeleton.Joints[JointID.ShoulderCenter]); ShoulderRight = GetScaledPosition(skeleton.Joints[JointID.ShoulderRight]); ShoulderLeft = GetScaledPosition(skeleton.Joints[JointID.ShoulderLeft]); AnkleRight = GetScaledPosition(skeleton.Joints[JointID.AnkleRight]); AnkleLeft = GetScaledPosition(skeleton.Joints[JointID.AnkleLeft]); FootLeft = GetScaledPosition(skeleton.Joints[JointID.FootLeft]); FootRight = GetScaledPosition(skeleton.Joints[JointID.FootRight]); WristLeft = GetScaledPosition(skeleton.Joints[JointID.WristLeft]); WristRight = GetScaledPosition(skeleton.Joints[JointID.WristRight]); ElbowLeft = GetScaledPosition(skeleton.Joints[JointID.ElbowLeft]); ElbowRight = GetScaledPosition(skeleton.Joints[JointID.ElbowRight]); KneeLeft = GetScaledPosition(skeleton.Joints[JointID.KneeLeft]); KneeRight = GetScaledPosition(skeleton.Joints[JointID.KneeRight]); HipCenter = GetScaledPosition(skeleton.Joints[JointID.HipCenter]); IsStable = barycenterHelper.IsStable(skeleton.TrackingID); RaiseSkeletonUpdate(new SkeletonEventArgs() { LeftHandPosition = skeleton.Joints[JointID.HandLeft].Position, RightHandPosition = skeleton.Joints[JointID.HandRight].Position }); } }