private Polyline getBodySegmentV(Microsoft.Research.Kinect.Nui.Runtime nui, Canvas skeleton, VirtualKinect.JointsCollection joints, Brush brush, params JointID[] ids) { PointCollection points = new PointCollection(ids.Length); for (int i = 0; i < ids.Length; ++i) { points.Add(Geometrics.getDisplayPosition(joints[ids[i]], nui, skeleton)); } Polyline polyline = new Polyline(); polyline.Points = points; polyline.Stroke = brush; polyline.StrokeThickness = 5; return polyline; }
public void nui_SkeletonFrameReadyV(VirtualKinect.SkeletonFrame skeletonFrame, Canvas skeleton, Microsoft.Research.Kinect.Nui.Runtime nui) { int iSkeleton = 0; Brush[] brushes = new Brush[6]; brushes[0] = new SolidColorBrush(Color.FromRgb(255, 0, 0)); brushes[1] = new SolidColorBrush(Color.FromRgb(0, 255, 0)); brushes[2] = new SolidColorBrush(Color.FromRgb(64, 255, 255)); brushes[3] = new SolidColorBrush(Color.FromRgb(255, 255, 64)); brushes[4] = new SolidColorBrush(Color.FromRgb(255, 64, 255)); brushes[5] = new SolidColorBrush(Color.FromRgb(128, 128, 255)); skeleton.Children.Clear(); foreach (VirtualKinect.SkeletonData data in skeletonFrame.Skeletons) { if (SkeletonTrackingState.Tracked == data.TrackingState) { // Draw bones Brush brush = brushes[iSkeleton % brushes.Length]; skeleton.Children.Add(getBodySegmentV(nui, skeleton, data.Joints, brush, JointID.HipCenter, JointID.Spine, JointID.ShoulderCenter, JointID.Head)); skeleton.Children.Add(getBodySegmentV(nui, skeleton, data.Joints, brush, JointID.ShoulderCenter, JointID.ShoulderLeft, JointID.ElbowLeft, JointID.WristLeft, JointID.HandLeft)); skeleton.Children.Add(getBodySegmentV(nui, skeleton, data.Joints, brush, JointID.ShoulderCenter, JointID.ShoulderRight, JointID.ElbowRight, JointID.WristRight, JointID.HandRight)); skeleton.Children.Add(getBodySegmentV(nui, skeleton, data.Joints, brush, JointID.HipCenter, JointID.HipLeft, JointID.KneeLeft, JointID.AnkleLeft, JointID.FootLeft)); skeleton.Children.Add(getBodySegmentV(nui, skeleton, data.Joints, brush, JointID.HipCenter, JointID.HipRight, JointID.KneeRight, JointID.AnkleRight, JointID.FootRight)); // Draw joints foreach (VirtualKinect.Joint joint in data.Joints) { Point jointPos = Geometrics.getDisplayPosition(joint, nui, skeleton); Line jointLine = new Line(); jointLine.X1 = jointPos.X - 3; jointLine.X2 = jointLine.X1 + 6; jointLine.Y1 = jointLine.Y2 = jointPos.Y; jointLine.Stroke = jointColors[joint.ID]; jointLine.StrokeThickness = 6; skeleton.Children.Add(jointLine); } } iSkeleton++; } // for each skeleton }
void nui_SkeletonFrameReady(object sender, VirtualKinect.SkeletonFrameReadyEventArgs e) { drawCore.nui_SkeletonFrameReadyV(e.SkeletonFrame, skeleton, nui); SkeletonFrameEventFileName.Text = e.eventFileName; }
void nui_DepthFrameReady(object sender, VirtualKinect.ImageFrameReadyEventArgs e) { VirtualKinect.PlanarImage image = e.ImageFrame.Image; drawCore.nui_DepthFrameReady(image.Bits, image.Width, image.Height, depth); DepthFrameEventFileName.Text = e.eventFileName; }
void nui_ColorFrameReady(object sender, VirtualKinect.ImageFrameReadyEventArgs e) { VirtualKinect.PlanarImage image = e.ImageFrame.Image; drawCore.nui_ColorFrameReady(image.Bits, image.Width, image.Height, image.BytesPerPixel, video); ColorFrameEventFileName.Text = e.eventFileName; }
public static Point getDisplayPosition(VirtualKinect.Joint joint, Microsoft.Research.Kinect.Nui.Runtime nui, Canvas skeleton) { return getDiplayPosition(joint.NUI.Position, nui, skeleton); }