private void kinectSensor_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e) { if (pause) { return; } Skeleton[] skeletons = new Skeleton[0]; using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame()) { if (skeletonFrame != null) { skeletons = new Skeleton[skeletonFrame.SkeletonArrayLength]; skeletonFrame.CopySkeletonDataTo(skeletons); } } using (DrawingContext dc = this.drawingGroup.Open()) { // Draw a transparent background to set the render size dc.DrawRectangle(Brushes.Black, null, new Rect(0.0, 0.0, RenderWidth, RenderHeight)); if (skeletons.Length != 0) { foreach (Skeleton skel in skeletons) { RenderClippedEdges(skel, dc); if (skel.TrackingState == SkeletonTrackingState.Tracked) { this.DrawBonesAndJoints(skel, dc); index++; if (actionState) { BitmapSource colorFrame = (BitmapSource)this.colorImageElement.Source; //BitmapSource skeletonFrame = (BitmapSource)this.skeletonImageElement.Source; actionData.add(colorFrame, null, skel); } if (index == 30) { index = 0; Posture posture = PostureRecognition.computePosture(skel, PostureType.Both); Text_PostureData.Text = posture.toJsonString(); } } else if (skel.TrackingState == SkeletonTrackingState.PositionOnly) { dc.DrawEllipse( this.centerPointBrush, null, this.SkeletonPointToScreen(skel.Position), BodyCenterThickness, BodyCenterThickness); } } } // prevent drawing outside of our render area this.drawingGroup.ClipGeometry = new RectangleGeometry(new Rect(0.0, 0.0, RenderWidth, RenderHeight)); } }