private void DrawLineBetweenJoints(Graphics g, Skeleton skel, SkeletonJoint.JointType j1, SkeletonJoint.JointType j2) { try { if (skel.State == Skeleton.SkeletonState.TRACKED) { SkeletonJoint joint1 = skel.getJoint(j1); SkeletonJoint joint2 = skel.getJoint(j2); if (joint1.Position.Z > 0 && joint2.Position.Z > 0) { Point j1PosEllipse = new Point(); Point j2PosEllipse = new Point(); NiTEWrapper.PointF j1PosLine = uTracker.ConvertJointCoordinatesToDepth(joint1.Position); NiTEWrapper.PointF j2PosLine = uTracker.ConvertJointCoordinatesToDepth(joint2.Position); j1PosEllipse.X = (int)j1PosLine.X - 5; j1PosEllipse.Y = (int)j1PosLine.Y - 5; j2PosEllipse.X = (int)j2PosLine.X - 5; j2PosEllipse.Y = (int)j2PosLine.Y - 5; j1PosLine.X -= 2; j1PosLine.Y -= 2; j2PosLine.X -= 2; j2PosLine.Y -= 2; g.DrawLine(new Pen(Brushes.White, 3), j1PosLine.X, j1PosLine.Y, j2PosLine.X, j2PosLine.Y); g.DrawEllipse(new Pen(Brushes.White, 5), new Rectangle(j1PosEllipse, new System.Drawing.Size(5, 5))); g.DrawEllipse(new Pen(Brushes.White, 5), new Rectangle(j2PosEllipse, new System.Drawing.Size(5, 5))); } } } catch (Exception) { } }
private void DrawLineBetweenJoints( Graphics g, Skeleton skel, SkeletonJoint.JointType j1, SkeletonJoint.JointType j2) { try { if (skel.State == Skeleton.SkeletonState.Tracked) { SkeletonJoint joint1 = skel.GetJoint(j1); SkeletonJoint joint2 = skel.GetJoint(j2); if (joint1.Position.Z > 0 && joint2.Position.Z > 0) { Point joint1PosEllipse = new Point(); Point joint2PosEllipse = new Point(); PointF joint1PosLine = this.userTracker.ConvertJointCoordinatesToDepth(joint1.Position); PointF joint2PosLine = this.userTracker.ConvertJointCoordinatesToDepth(joint2.Position); joint1PosEllipse.X = (int)joint1PosLine.X - 5; joint1PosEllipse.Y = (int)joint1PosLine.Y - 5; joint2PosEllipse.X = (int)joint2PosLine.X - 5; joint2PosEllipse.Y = (int)joint2PosLine.Y - 5; joint1PosLine.X -= 2; joint1PosLine.Y -= 2; joint2PosLine.X -= 2; joint2PosLine.Y -= 2; g.DrawLine(new Pen(Brushes.White, 3), joint1PosLine, joint2PosLine); g.DrawEllipse(new Pen(Brushes.White, 5), new Rectangle(joint1PosEllipse, new Size(5, 5))); g.DrawEllipse(new Pen(Brushes.White, 5), new Rectangle(joint2PosEllipse, new Size(5, 5))); } } } catch (Exception) { } }
public SkeletonJoint getJoint(SkeletonJoint.JointType type) { if (!_states.ContainsKey(type)) _states[type] = new SkeletonJoint(Skeleton_getJoint(this.Handle, type)); return _states[type]; }
static extern IntPtr Skeleton_getJoint(IntPtr objectHandler, SkeletonJoint.JointType type);
public SkeletonJoint GetJoint(SkeletonJoint.JointType type) { if (!this.states.ContainsKey(type)) { this.states[type] = new SkeletonJoint(Skeleton_getJoint(this.Handle, type)); } return this.states[type]; }
internal void DrawCirlce(Skeleton skeleton, SkeletonJoint.JointType jointType, DrawingContext dc, double radius) { if (skeleton == null) return; Point3D jointPoint = skeleton.GetJoint(jointType).Position; dc.DrawEllipse(TorqueBrush, TorquePen, SkeletonPointToScreen(jointPoint), radius, radius); }
/// <summary> /// Draws a bone line between two joints /// </summary> /// <param name="skeleton">skeleton to draw bones from</param> /// <param name="drawingContext">drawing context to draw to</param> /// <param name="jointType0">joint to start drawing from</param> /// <param name="jointType1">joint to end drawing at</param> private void drawBone(Skeleton skeleton, DrawingContext drawingContext, SkeletonJoint.JointType jointType0, SkeletonJoint.JointType jointType1) { if (skeleton.State != Skeleton.SkeletonState.Tracked) return; SkeletonJoint joint0 = skeleton.GetJoint(jointType0); SkeletonJoint joint1 = skeleton.GetJoint(jointType1); // If we can't find either of these joints, exit if (joint0.Position.Z <=0 || joint1.Position.Z <=0) { return; } // We assume all drawn bones are inferred unless BOTH joints are tracked Pen drawPen = this.trackedBonePen; drawingContext.DrawLine(drawPen, this.SkeletonPointToScreen(joint0.Position), this.SkeletonPointToScreen(joint1.Position)); }