Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You could capture the SkeletonFrameReady event and save the last captured skeleton to a global variable, which you can access from your button click event.</p> <p>For example:</p> <pre><code>private Skeleton[] skeletons = new Skeleton[0]; private void SensorSkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e) { Skeleton[] skeletons = new Skeleton[0]; using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame()) { if (skeletonFrame != null) { skeletons = new Skeleton[skeletonFrame.SkeletonArrayLength]; skeletonFrame.CopySkeletonDataTo(skeletons); } } } </code></pre> <p>Now you have an array (<em>skeletons</em>) of the last SkeletonFrameReady event.</p> <p>Based on comments made below, you need to upgrade to v1.6 of the SDK and go through the examples provided by Microsoft. Although they may not do exactly what you are wanting for your immediate project they will teach you the <strong>basic fundamentals</strong> of working with the Microsoft Kinect for Windows, and give you an understanding of how to work with the sensor.</p> <p>The example you most want to look at, for your immediate situation, is the <em>SkeletonBasics-WPF</em> example. This will show you how to track the skeleton and pull data from it. It also shows you exactly how draw items onto, and between, the tracked points.</p> <p>For your situation the most relevant piece is the <em>DrawBonesAndJoints</em> function:</p> <pre><code>private void DrawBonesAndJoints(Skeleton skeleton, DrawingContext drawingContext) { // Render Torso this.DrawBone(skeleton, drawingContext, JointType.Head, JointType.ShoulderCenter); this.DrawBone(skeleton, drawingContext, JointType.ShoulderCenter, JointType.ShoulderLeft); this.DrawBone(skeleton, drawingContext, JointType.ShoulderCenter, JointType.ShoulderRight); this.DrawBone(skeleton, drawingContext, JointType.ShoulderCenter, JointType.Spine); this.DrawBone(skeleton, drawingContext, JointType.Spine, JointType.HipCenter); this.DrawBone(skeleton, drawingContext, JointType.HipCenter, JointType.HipLeft); this.DrawBone(skeleton, drawingContext, JointType.HipCenter, JointType.HipRight); // Left Arm this.DrawBone(skeleton, drawingContext, JointType.ShoulderLeft, JointType.ElbowLeft); this.DrawBone(skeleton, drawingContext, JointType.ElbowLeft, JointType.WristLeft); this.DrawBone(skeleton, drawingContext, JointType.WristLeft, JointType.HandLeft); // Right Arm this.DrawBone(skeleton, drawingContext, JointType.ShoulderRight, JointType.ElbowRight); this.DrawBone(skeleton, drawingContext, JointType.ElbowRight, JointType.WristRight); this.DrawBone(skeleton, drawingContext, JointType.WristRight, JointType.HandRight); // Left Leg this.DrawBone(skeleton, drawingContext, JointType.HipLeft, JointType.KneeLeft); this.DrawBone(skeleton, drawingContext, JointType.KneeLeft, JointType.AnkleLeft); this.DrawBone(skeleton, drawingContext, JointType.AnkleLeft, JointType.FootLeft); // Right Leg this.DrawBone(skeleton, drawingContext, JointType.HipRight, JointType.KneeRight); this.DrawBone(skeleton, drawingContext, JointType.KneeRight, JointType.AnkleRight); this.DrawBone(skeleton, drawingContext, JointType.AnkleRight, JointType.FootRight); // Render Joints foreach (Joint joint in skeleton.Joints) { Brush drawBrush = null; if (joint.TrackingState == JointTrackingState.Tracked) { drawBrush = this.trackedJointBrush; } else if (joint.TrackingState == JointTrackingState.Inferred) { drawBrush = this.inferredJointBrush; } if (drawBrush != null) { drawingContext.DrawEllipse(drawBrush, null, this.SkeletonPointToScreen(joint.Position), JointThickness, JointThickness); } } } </code></pre> <p>Because you don't care about bones, you can remove the function calls that draw them:</p> <pre><code>private void DrawBonesAndJoints(Skeleton skeleton, DrawingContext drawingContext) { // Render Joints foreach (Joint joint in skeleton.Joints) { Brush drawBrush = null; if (joint.TrackingState == JointTrackingState.Tracked) { drawBrush = this.trackedJointBrush; } else if (joint.TrackingState == JointTrackingState.Inferred) { drawBrush = this.inferredJointBrush; } if (drawBrush != null) { drawingContext.DrawEllipse(drawBrush, null, this.SkeletonPointToScreen(joint.Position), JointThickness, JointThickness); } } } </code></pre> <p>Now you have a program that will draw dots on all the joints. If all you want are the hands...</p> <pre><code>private void DrawBonesAndJoints(Skeleton skeleton, DrawingContext drawingContext) { drawingContext.DrawEllipse(trackedJointBrush, null, SkeletonPointToScreen(skeleton.Joints[JointType.HandLeft].Position), JointThickness, JointThickness); drawingContext.DrawEllipse(trackedJointBrush, null, SkeletonPointToScreen(skeleton.Joints[JointType.HandRight].Position), JointThickness, JointThickness); } </code></pre> <p>You'll have two little dots following your hands around now.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload