private void ProcessFrame(SkeletonFrame frame) { foreach (var skeleton in frame.Skeletons) { if (skeleton.TrackingState != SkeletonTrackingState.Tracked) { continue; } foreach (Joint joint in skeleton.Joints) { if (joint.Position.W < 0.8f || joint.TrackingState != JointTrackingState.Tracked) { continue; } if (joint.ID == JointID.HandRight) { gestureRecognizer.Add(joint.Position, kinectRuntime.SkeletonEngine); } } skeletonDisplayManager.Draw(frame); } }
void kinectRuntime_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e) { SkeletonFrame skeletonFrame = e.SkeletonFrame; foreach (SkeletonData data in skeletonFrame.Skeletons) { if (data.TrackingState != SkeletonTrackingState.Tracked) { continue; } barycenterHelper.Add(data.Position.ToVector3(), data.TrackingID); if (!barycenterHelper.IsStable(data.TrackingID)) { continue; } foreach (Joint joint in data.Joints) { if (joint.Position.W < 0.8f || joint.TrackingState != JointTrackingState.Tracked) { continue; } if (joint.ID == JointID.HandRight) { rightHandGestureRecognizer.Add(joint.Position, kinectRuntime.SkeletonEngine); Trace.WriteLine(Gesture.Content = "HandRight.Add"); } } // ポーズの検出 postureRecognizer.TrackPostures(data); } // スケルトンの描画 skeletonDisplayManager.Draw(e.SkeletonFrame); labelPose.Content = "Pose: " + postureRecognizer.CurrentPosture.ToString(); }