当前位置: 首页>>代码示例>>C#>>正文


C# SkeletonData类代码示例

本文整理汇总了C#中SkeletonData的典型用法代码示例。如果您正苦于以下问题:C# SkeletonData类的具体用法?C# SkeletonData怎么用?C# SkeletonData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SkeletonData类属于命名空间,在下文中一共展示了SkeletonData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: nui_SkeletonFrameReady

        void nui_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
        {
            SkeletonFrame allSkeletons = e.SkeletonFrame;

            //get the first tracked skeleton
            SkeletonData skeleton = (from s in allSkeletons.Skeletons
                                     where s.TrackingState == SkeletonTrackingState.Tracked
                                     select s).FirstOrDefault();
            if (skeleton != null)
            {
                this._skel = skeleton;
                Joint head = skeleton.Joints[JointID.Head];
                HumanSkeleton hs = new HumanSkeleton(skeleton.Joints);
                NaoSkeleton ns = new NaoSkeleton(hs);
                UpdateTextBoxes(ns, hs);
                controller.update(ns);

                SetLineAngle(RightArmTopDown, Util.radToDeg(hs.RightShoulderYaw));
                SetLineAngle(LeftArmTopDown, Util.radToDeg(hs.LeftShoulderYaw));
                SetLineAngle(RightArmFront, Util.radToDeg(-hs.RightShoulderPitch) + 90);
                SetLineAngle(LeftArmFront, Util.radToDeg(hs.LeftShoulderPitch) - 90);
                SetLineAngle(RightArm, Util.radToDeg(-hs.RightShoulderRoll) + 90);
                SetLineAngle(LeftArm, Util.radToDeg(hs.LeftShoulderRoll) - 90);
            }
        }
开发者ID:omanamos,项目名称:kinect-nao,代码行数:25,代码来源:MainWindow.xaml.cs

示例2: DrawSkeleton

        private void DrawSkeleton(SkeletonData skeleton)
        {
            if (markers == null)
            {
                markers = new Dictionary<JointID, Ellipse>();
            }

            if (markers.Count == 0)
            {
                foreach (Joint joint in skeleton.Joints)
                {
                    if (!markers.ContainsKey(joint.ID))
                    {
                        Ellipse jointEllipse = Copy(EllipseTemplate);
                        jointEllipse.Visibility = Visibility.Visible;

                        markers.Add(joint.ID, jointEllipse);

                        MainCanvas.Children.Add(markers[joint.ID]);
                    }
                }
            }

            foreach (Joint joint in skeleton.Joints)
            {
                SetUIElementPosition(markers[joint.ID], joint);
            }
        }
开发者ID:NashDotNet,项目名称:Intro-to-Developing-for-the-Kinect,代码行数:28,代码来源:MainWindow.xaml.cs

示例3: processSkeletonFrame

        //This function will be implemented by you in the subclass files provided.
        //A simple example of highlighting targets when hovered over has been provided below

        //Note: targets is a dictionary that allows you to retrieve the corresponding target on screen
        //and manipulate its state and position, as well as hide/show it (see class defn. below).
        //It is indexed from 1, thus you can retrieve an individual target with the expression
        //targets[3], which would retrieve the target labeled "3" on screen.
        public virtual void processSkeletonFrame(SkeletonData skeleton, Dictionary<int, Target> targets)
        {

            /*Example implementation*/

            foreach (var target in targets)
            {
                Target cur = target.Value;
                int targetID = cur.id; //ID in range [1..5]

                //Scale the joints to the size of the window
                Joint leftHand = skeleton.Joints[JointID.HandLeft].ScaleTo(640, 480, window.k_xMaxJointScale, window.k_yMaxJointScale);
                Joint rightHand = skeleton.Joints[JointID.HandRight].ScaleTo(640, 480, window.k_xMaxJointScale, window.k_yMaxJointScale);
                
                //Calculate how far our left hand is from the target in both x and y directions
                double deltaX_left = Math.Abs(leftHand.Position.X - cur.getXPosition());
                double deltaY_left = Math.Abs(leftHand.Position.Y - cur.getYPosition());

                //Calculate how far our right hand is from the target in both x and y directions
                double deltaX_right = Math.Abs(rightHand.Position.X - cur.getXPosition());
                double deltaY_right = Math.Abs(rightHand.Position.Y - cur.getYPosition());

                //If we have a hit in a reasonable range, highlight the target
                if (deltaX_left < 15 && deltaY_left < 15 || deltaX_right < 15 && deltaY_right < 15)
                {
                    cur.setTargetSelected();
                }
                else
                {
                    cur.setTargetUnselected();
                }
            }

        }
开发者ID:thoschmidt,项目名称:shoopdoup,代码行数:41,代码来源:SkeletonController.cs

示例4: DrawSkeleton

        private void DrawSkeleton(SkeletonData data)
        {
            skeletonCanvas.Children.Clear();

            // Draw bones
            Brush brush = new SolidColorBrush(Colors.Green);
            skeletonCanvas.Children.Add(GetBodySegment(data.Joints, brush, JointID.HipCenter, JointID.Spine, JointID.ShoulderCenter, JointID.Head));
            skeletonCanvas.Children.Add(GetBodySegment(data.Joints, brush, JointID.ShoulderCenter, JointID.ShoulderLeft, JointID.ElbowLeft, JointID.WristLeft, JointID.HandLeft));
            skeletonCanvas.Children.Add(GetBodySegment(data.Joints, brush, JointID.ShoulderCenter, JointID.ShoulderRight, JointID.ElbowRight, JointID.WristRight, JointID.HandRight));
            skeletonCanvas.Children.Add(GetBodySegment(data.Joints, brush, JointID.HipCenter, JointID.HipLeft, JointID.KneeLeft, JointID.AnkleLeft, JointID.FootLeft));
            skeletonCanvas.Children.Add(GetBodySegment(data.Joints, brush, JointID.HipCenter, JointID.HipRight, JointID.KneeRight, JointID.AnkleRight, JointID.FootRight));

            // Draw joints
            foreach (Line jointLine in
                from Joint joint in data.Joints
                let jointPos = GetDisplayPosition(joint)
                select new Line
                {
                    Stroke = jointColors[joint.ID],
                    StrokeThickness = 6,
                    X1 = jointPos.X - 3,
                    X2 = jointPos.X + 3,
                    Y1 = jointPos.Y,
                    Y2 = jointPos.Y
                }) { skeletonCanvas.Children.Add(jointLine); }
        }
开发者ID:smanoharan,项目名称:314Kinect,代码行数:26,代码来源:SkeletonDrawer.cs

示例5: detect_Pause

 private void detect_Pause(SkeletonData skeleton)
 {
     float hipX = Math.Abs(skeleton.Joints[JointID.HipCenter].Position.Y), hipY = Math.Abs(skeleton.Joints[JointID.HipCenter].Position.X),
         hipZ = Math.Abs(skeleton.Joints[JointID.HipCenter].Position.Z), rHandX = Math.Abs(skeleton.Joints[JointID.HandRight].Position.X),
         rHandY = Math.Abs(skeleton.Joints[JointID.HandRight].Position.Y), rHandZ = Math.Abs(skeleton.Joints[JointID.HandRight].Position.Z),
         lHandX = Math.Abs(skeleton.Joints[JointID.HandLeft].Position.X), lHandY = Math.Abs(skeleton.Joints[JointID.HandLeft].Position.Y),
         lHandZ = Math.Abs(skeleton.Joints[JointID.HandLeft].Position.Z), lElbowY = Math.Abs(skeleton.Joints[JointID.ElbowLeft].Position.Y),
         spineY = Math.Abs(skeleton.Joints[JointID.Spine].Position.Y);
     detected = false;
     if(DEBUG)
         textBox1.AppendText("Checking for pause:\n");
     if (DEBUG2)
     {
         //textBox1.AppendText("" + (lHandX <= (hipX + VAL)) + " | " + (lHandX >= (hipX - VAL)) + " | " + (lHandZ >= (hipZ + VAL)) + "\n");
         textBox1.AppendText("hip: " + hipX + " " + hipY + " " + hipZ + " | " + "lHand: " + lHandX + " " + lHandY + " " + lHandZ + "\n");
     }
     if (lHandX <= (hipX + VAL) && lHandX >= (hipX - VAL) && (lHandZ + VAL) <= hipZ && lHandY <= (lElbowY + VAL))
     {
         if(DEBUG)
             textBox1.AppendText("Passed test.\n");
         static_Count++;
         shuffle.Opacity = 0.25;
         wave.Opacity = 0.25;
         detected = true;
         if (static_Count >= 4)
         {
             if (DEBUG)
                 textBox1.AppendText("Changing button opacity.\n");
             pause.Opacity = 1;
             static_Count = 3;
         }
     }
 }
开发者ID:pedrotanaka,项目名称:CS160-Individual-Programming-Assignment-2,代码行数:33,代码来源:MainWindow.xaml.cs

示例6: processSkeletonFrame

        //Note: targets is a dictionary that allows you to retrieve the corresponding target on screen
        //and manipulate its state and position, as well as hide/show it (see class defn. below).
        //It is indexed from 1, thus you can retrieve an individual target with the expression
        //targets[3], which would retrieve the target labeled "3" on screen.
        public override void processSkeletonFrame(SkeletonData skeleton, Dictionary<int, Target> targets)
        {
            Joint head = skeleton.Joints[JointID.Head].ScaleTo(640, 480, window.k_xMaxJointScale, window.k_yMaxJointScale);
            //Joint center = skeleton.Joints[JointID.HipCenter].ScaleTo(640, 480, window.k_xMaxJointScale, window.k_yMaxJointScale);
            Joint leftShoulder = skeleton.Joints[JointID.ShoulderLeft].ScaleTo(640, 480, window.k_xMaxJointScale, window.k_yMaxJointScale);
            Joint rightShoulder = skeleton.Joints[JointID.ShoulderRight].ScaleTo(640, 480, window.k_xMaxJointScale, window.k_yMaxJointScale);
            Joint leftHand = skeleton.Joints[JointID.HandLeft].ScaleTo(640, 480, window.k_xMaxJointScale, window.k_yMaxJointScale);
            Joint rightHand = skeleton.Joints[JointID.HandRight].ScaleTo(640, 480, window.k_xMaxJointScale, window.k_yMaxJointScale);

            //Check targets for highlighting and selection
            for (var i = 1; i <= 5; i++)
            {
                double targetXPos = targets[i].getXPosition();

                //Check to see which region
                if (Math.Abs(targetXPos - head.Position.X) < 40)
                {
                    highlighting = i;

                    //Check to see if the arms are above the head
                    if (leftHand.Position.Y < leftShoulder.Position.Y || rightHand.Position.Y < leftShoulder.Position.Y || leftHand.Position.Y < rightShoulder.Position.Y || rightHand.Position.Y < rightShoulder.Position.Y)
                    {
                        selecting = i;
                    }
                }
            }

            //Reflect the current highlighting/selection state in the targets
            for (var i = 1; i <= 5; i++)
            {
                targets[i].setTargetUnselected();
            }
            if (highlighting > 0) targets[highlighting].setTargetHighlighted();
            if (selecting > 0) targets[selecting].setTargetSelected();
        }
开发者ID:mrcc912,项目名称:Displayful,代码行数:39,代码来源:CustomController1.cs

示例7: ProcessData

        /// <summary>
        /// Crunches Kinect SDK's Skeleton Data and spits out a format more useful for DTW
        /// </summary>
        /// <param name="data">Kinect SDK's Skeleton Data</param>
        public static void ProcessData(SkeletonData data)
        {
            // Extract the coordinates of the points.
            var p = new Point3D[6];
            Point3D shoulderRight = new Point3D(), shoulderLeft = new Point3D();
            foreach (Joint j in data.Joints)
            {
                switch (j.ID)
                {
                    case JointID.HandLeft:
                        p[0] = new Point3D(j.Position.X, j.Position.Y, j.Position.Z);
                        break;
                    case JointID.WristLeft:
                        p[1] = new Point3D(j.Position.X, j.Position.Y, j.Position.Z);
                        break;
                    case JointID.ElbowLeft:
                        p[2] = new Point3D(j.Position.X, j.Position.Y, j.Position.Z);
                        break;
                    case JointID.ElbowRight:
                        p[3] = new Point3D(j.Position.X, j.Position.Y, j.Position.Z);
                        break;
                    case JointID.WristRight:
                        p[4] = new Point3D(j.Position.X, j.Position.Y, j.Position.Z);
                        break;
                    case JointID.HandRight:
                        p[5] = new Point3D(j.Position.X, j.Position.Y, j.Position.Z);
                        break;
                    case JointID.ShoulderLeft:
                        shoulderLeft = new Point3D(j.Position.X, j.Position.Y, j.Position.Z);
                        break;
                    case JointID.ShoulderRight:
                        shoulderRight = new Point3D(j.Position.X, j.Position.Y, j.Position.Z);
                        break;
                }
            }

            // Centre the data
            var center = new Point3D((shoulderLeft.X + shoulderRight.X) / 2, (shoulderLeft.Y + shoulderRight.Y) / 2, (shoulderLeft.Z + shoulderRight.Z) / 2);
            for (int i = 0; i < 6; i++)
            {
                p[i].X -= center.X;
                p[i].Y -= center.Y;
                p[i].Z -= center.Z;
            }

            // Normalization of the coordinates
            double shoulderDist =
                Math.Sqrt(Math.Pow((shoulderLeft.X - shoulderRight.X), 2) +
                          Math.Pow((shoulderLeft.Y - shoulderRight.Y), 2) +
                          Math.Pow((shoulderLeft.Z - shoulderRight.Z), 2));
            for (int i = 0; i < 6; i++)
            {
                p[i].X /= shoulderDist;
                p[i].Y /= shoulderDist;
                p[i].Z /= shoulderDist;
            }

            // Launch the event!
            Skeleton3DdataCoordReady(null, new Skeleton3DdataCoordEventArgs(p));
        }
开发者ID:ahsquared,项目名称:KinectGestureInteraction,代码行数:64,代码来源:Skeleton3DDataExtract.cs

示例8: CalculateTorsoInclination

        public static Vector3D CalculateTorsoInclination(SkeletonData bodyPartData)
        {
            Vector hipCenterPosition = bodyPartData.Joints[JointID.HipCenter].Position;
            Vector shoulderCenterPosition = bodyPartData.Joints[JointID.ShoulderCenter].Position;

            return new Vector3D(shoulderCenterPosition.X - hipCenterPosition.X, shoulderCenterPosition.Y - hipCenterPosition.Y,
                shoulderCenterPosition.Z - hipCenterPosition.Z);
        }
开发者ID:drrobson,项目名称:Group42_FYDP,代码行数:8,代码来源:TorsoOrientation.cs

示例9: SkeletonProcessing

 public SkeletonProcessing(SkeletonData _skeleton, float _scale)
 {
     skeleton = _skeleton;
     screenheight = Height;
     screenwidth = Width;
     scale = _scale;
     coords = new coord[11];
 }
开发者ID:CS321-Development-Group,项目名称:SimonSaysKinect,代码行数:8,代码来源:SkeletonProcessing.cs

示例10: CalculateHeadInclination

        public static Vector3D CalculateHeadInclination(SkeletonData bodyPartData)
        {
            Vector centerShoulderPosition = bodyPartData.Joints[JointID.ShoulderCenter].Position;
            Vector headPosition = bodyPartData.Joints[JointID.Head].Position;

            return new Vector3D(headPosition.X - centerShoulderPosition.X, headPosition.Y - centerShoulderPosition.Y,
                headPosition.Z - centerShoulderPosition.Z);
        }
开发者ID:drrobson,项目名称:Group42_FYDP,代码行数:8,代码来源:HeadOrientation.cs

示例11: processSkeletonFrame

        public override void processSkeletonFrame(SkeletonData skeleton, Dictionary<int, Target> targets)
        {
            Joint leftHand = skeleton.Joints[JointID.HandLeft].ScaleTo(640, 480, window.k_xMaxJointScale, window.k_yMaxJointScale);
            Joint head = skeleton.Joints[JointID.ShoulderCenter].ScaleTo(640, 480, window.k_xMaxJointScale, window.k_yMaxJointScale);

            // If we are currently in selection mode
            if (selectMode)
            {
                // Leave selection mode if left hand is below head
                if (leftHand.Position.Y > head.Position.Y)
                {
                    selectMode = false;
                    foreach (var target in targets)
                    {
                        target.Value.setTargetUnselected();
                    }
                }
                // Compute which target to select based on horizontal distance of right hand from center position
                // Note: Target keys must be in the range 1..targets.Count
                else
                {
                    Joint rightHand = skeleton.Joints[JointID.HandRight].ScaleTo(640, 480, window.k_xMaxJointScale, window.k_yMaxJointScale);
                    double deltaX = rightHand.Position.X - centerX;;
                    int targetToSelect = Math.Min(targets.Count, Math.Max(1, (int)Math.Ceiling((deltaX / rangeX + 0.5) * targets.Count)));
                    foreach (var target in targets)
                    {
                        if (target.Key == targetToSelect)
                        {
                            if (rightHandTargetID < 0)
                            {
                                startTimer(target.Value, 1.5);
                            }
                            else if (rightHandTargetID != target.Key)
                            {
                                stopTimer(rightHandTarget);
                                startTimer(target.Value, 1.5);
                            }
                        }
                        else
                        {
                            target.Value.setTargetUnselected();
                        }
                    }
                }
            }

            // Not in selection mode
            else
            {
                // Enter selection mode if left hand is above head
                if (leftHand.Position.Y < head.Position.Y)
                {
                    selectMode = true;
                    Joint rightHand = skeleton.Joints[JointID.HandRight].ScaleTo(640, 480, window.k_xMaxJointScale, window.k_yMaxJointScale);
                    centerX = rightHand.Position.X;
                }
            }
        }
开发者ID:nhippenmeyer,项目名称:CS247,代码行数:58,代码来源:CustomController2.cs

示例12: processSkeletonFrame

        public override void processSkeletonFrame(SkeletonData skeleton, Dictionary<int, Target> targets)
        {
            // Gets right shoulder position
            Point rightShoulderPosition;
            Joint rightShoulder = skeleton.Joints[JointID.ShoulderRight];
            rightShoulderPosition = new Point(rightShoulder.Position.X, rightShoulder.Position.Z);

            Point leftShoulderPosition;
            Joint leftShoulder = skeleton.Joints[JointID.ShoulderLeft];
            leftShoulderPosition = new Point(leftShoulder.Position.X, leftShoulder.Position.Z);

            double shoulderDifferential = leftShoulderPosition.Y - rightShoulderPosition.Y;

            if (shoulderDifferential < -0.08)       // Rightmost (i.e. 5)
            {
                targets[1].setTargetUnselected();
                targets[2].setTargetUnselected();
                targets[3].setTargetUnselected();
                targets[4].setTargetUnselected();
                targets[5].setTargetSelected();

            }
            else if (shoulderDifferential < -0.025 && shoulderDifferential > -0.08)   // "4"
            {
                targets[1].setTargetUnselected();
                targets[2].setTargetUnselected();
                targets[3].setTargetUnselected();
                targets[4].setTargetSelected();
                targets[5].setTargetUnselected();

            }
            else if (shoulderDifferential > -0.025 && shoulderDifferential < 0.025)   // "3"
            {
                targets[1].setTargetUnselected();
                targets[2].setTargetUnselected();
                targets[3].setTargetSelected();
                targets[4].setTargetUnselected();
                targets[5].setTargetUnselected();

            }
            else if (shoulderDifferential > 0.025 && shoulderDifferential < 0.08)    // "2"
            {
                targets[1].setTargetUnselected();
                targets[2].setTargetSelected();
                targets[3].setTargetUnselected();
                targets[4].setTargetUnselected();
                targets[5].setTargetUnselected();
            }
            else if (shoulderDifferential > 0.08)       // "1" or leftmost
            {
                targets[1].setTargetSelected();
                targets[2].setTargetUnselected();
                targets[3].setTargetUnselected();
                targets[4].setTargetUnselected();
                targets[5].setTargetUnselected();

            }
        }
开发者ID:tatermelon,项目名称:cs247_p3,代码行数:58,代码来源:CustomController1.cs

示例13: UpdateJointPosition

        //void UpdateSegmentPosition(JointID j1, JointID j2, PlayerUtils.Segment seg)
        //{
        //    var bone = new PlayerUtils.Bone(j1, j2);
        //    if (segments.ContainsKey(bone))
        //    {
        //        PlayerUtils.BoneData data = segments[bone];
        //        data.UpdateSegment(seg);
        //        segments[bone] = data;
        //    }
        //    else
        //        segments.Add(bone, new PlayerUtils.BoneData(seg));
        //}
        //public void UpdateBonePosition(Microsoft.Research.Kinect.Nui.JointsCollection joints, JointID j1, JointID j2)
        //{
        //    var seg = new PlayerUtils.Segment(joints[j1].Position.X * playerScale + playerCenter.X,
        //                          playerCenter.Y - joints[j1].Position.Y * playerScale,
        //                          joints[j2].Position.X * playerScale + playerCenter.X,
        //                          playerCenter.Y - joints[j2].Position.Y * playerScale);
        //    seg.radius = Math.Max(3.0, playerBounds.Height * BONE_SIZE) / 2;
        //    UpdateSegmentPosition(j1, j2, seg);
        //}
        public void UpdateJointPosition(SkeletonData data)
        {
            this.skeleton = data;
            //var seg = new PlayerUtils.Segment(joints[j].Position.X * playerScale + playerCenter.X,
            //                      playerCenter.Y - joints[j].Position.Y * playerScale);

            //seg.radius = playerBounds.Height * ((j == JointID.Head) ? HEAD_SIZE : HAND_SIZE) / 2;
            //UpdateSegmentPosition(j, j, seg);
        }
开发者ID:grazulis,项目名称:Starfighter-K,代码行数:30,代码来源:Player.cs

示例14: FromSkeleton

 public static Body FromSkeleton(SkeletonData skeleton)
 {
     return new Body
                {
                    Head = skeleton.Joints[JointID.Head].Position,
                    RightHand = skeleton.Joints[JointID.HandRight].Position,
                    LeftHand = skeleton.Joints[JointID.HandLeft].Position,
                };
 }
开发者ID:guozanhua,项目名称:KinectGestures,代码行数:9,代码来源:Body.cs

示例15: KinectPointerEventArgs

 public KinectPointerEventArgs(Vector3 righthand, Vector3 lefthand,Vector3 previousrighthand,Vector3 previouslefthand,SkeletonData data,int player)
 {
     this.RightHandPosition = righthand;
     this.LeftHandPosition = lefthand;
     this.PreviousLeftHandPosition = previouslefthand;
     this.PreviousRightHandPosition = previousrighthand;
     this.SkeletonData = data;
     this.PlayerID = player;
 }
开发者ID:Wotuu,项目名称:GDD_Game_2,代码行数:9,代码来源:KinectPointerEventArgs.cs


注:本文中的SkeletonData类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。