将图像放在Kinect Skeleton骨骼上

时间:2014-10-21 01:10:37

标签: c# visual-studio-2010 kinect

我目前有一个功能正常的Kinect骨架。在骨头上,我想要放置一个角色的手臂,腿,头等图像。我该怎么做呢?我假设我在绘制骨头时必须以某种方式添加图像,但除此之外我不知道该怎么做。这是我绘制骨骼的功能。任何帮助,将不胜感激。

 private void DrawBonesAndJoints(DrawingContext drawingContext)
        {
            if (this.ShowBones)
            {
                // Render Torso
                this.DrawBone(drawingContext, JointType.Head, JointType.ShoulderCenter);
                this.DrawBone(drawingContext, JointType.ShoulderCenter, JointType.ShoulderLeft);
                this.DrawBone(drawingContext, JointType.ShoulderCenter, JointType.ShoulderRight);
                this.DrawBone(drawingContext, JointType.ShoulderCenter, JointType.Spine);
                this.DrawBone(drawingContext, JointType.Spine, JointType.HipCenter);
                this.DrawBone(drawingContext, JointType.HipCenter, JointType.HipLeft);
                this.DrawBone(drawingContext, JointType.HipCenter, JointType.HipRight);

                // Left Arm
                this.DrawBone(drawingContext, JointType.ShoulderLeft, JointType.ElbowLeft);
                this.DrawBone(drawingContext, JointType.ElbowLeft, JointType.WristLeft);
                this.DrawBone(drawingContext, JointType.WristLeft, JointType.HandLeft);

                // Right Arm
                this.DrawBone(drawingContext, JointType.ShoulderRight, JointType.ElbowRight);
                this.DrawBone(drawingContext, JointType.ElbowRight, JointType.WristRight);
                this.DrawBone(drawingContext, JointType.WristRight, JointType.HandRight);

                // Left Leg
                this.DrawBone(drawingContext, JointType.HipLeft, JointType.KneeLeft);
                this.DrawBone(drawingContext, JointType.KneeLeft, JointType.AnkleLeft);
                this.DrawBone(drawingContext, JointType.AnkleLeft, JointType.FootLeft);

                // Right Leg
                this.DrawBone(drawingContext, JointType.HipRight, JointType.KneeRight);
                this.DrawBone(drawingContext, JointType.KneeRight, JointType.AnkleRight);
                this.DrawBone(drawingContext, JointType.AnkleRight, JointType.FootRight);
            }

            if (this.ShowJoints)
            {
                // Render Joints
                foreach (JointMapping joint in this.JointMappings.Values)
                {
                    Brush drawBrush = null;
                    switch (joint.Joint.TrackingState)
                    {
                        case JointTrackingState.Tracked:
                            drawBrush = this.trackedJointBrush;
                            break;
                        case JointTrackingState.Inferred:
                            drawBrush = this.inferredJointBrush;
                            break;
                    }

                    if (drawBrush != null)
                    {
                        drawingContext.DrawEllipse(drawBrush, null, joint.MappedPoint, JointThickness * this.ScaleFactor, JointThickness * this.ScaleFactor);
                    }
                }
            }
        }

1 个答案:

答案 0 :(得分:0)

首先介绍一些基本的动画程序,例如在这个骨架跟踪场景中。 Skeletal Tracking Fundamentals。它包含您想要在骨架上绘制图像的内容。