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


C# Skeleton.ToList方法代码示例

本文整理汇总了C#中Microsoft.Kinect.Skeleton.ToList方法的典型用法代码示例。如果您正苦于以下问题:C# Skeleton.ToList方法的具体用法?C# Skeleton.ToList怎么用?C# Skeleton.ToList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Kinect.Skeleton的用法示例。


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

示例1: refreshSkeletonPositions

            /// <summary>
            /// SkeletonFrameReady gets fired every skeleton frame update, and refreshes the LocatedSensor's
            ///  global and relative skeleton maps
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void refreshSkeletonPositions(object sender, SkeletonFrameReadyEventArgs e)
            {
                using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame()) {
                    if (skeletonFrame != null) {
                        // First, get the relative skeletons - easy peasy
                        Skeleton[] skeletonsR = new Skeleton[skeletonFrame.SkeletonArrayLength];
                        skeletonFrame.CopySkeletonDataTo(skeletonsR);
                        this.relativeSkeletons = skeletonsR.ToList<Skeleton>();

                        // Now global skeletons...
                        // First, clear our global skeletons list.
                        //  We'll be building this back up from scratch here
                        this.globalSkeletons.Clear();
                        // Next, iterate through all the skeletons, applying a rotation and translation
                        //  to get us into global coordinates
                        foreach (Skeleton skel in this.relativeSkeletons) {
                            // Add a temporary skeleton object to store transformed
                            //  data into
                            Skeleton tempSkel = skel;

                            foreach (Joint j in skel.Joints){
                                // Make a new joint, then put it into our temporary joint
                                //  collection
                                JointType type = j.JointType;
                                Joint tempJoint = tempSkel.Joints[type];
                                // Copy the current joint state
                                JointTrackingState tracking = j.TrackingState;
                                tempJoint.TrackingState = tracking;

                                // However, we transform the position of the joint at least
                                SkeletonPoint shiftedPoint = new SkeletonPoint();
                                // Rotate the points
                                DenseMatrix point = new DenseMatrix(1, 3);
                                point[0, 0] = j.Position.X;
                                point[0, 1] = j.Position.Y;
                                point[0, 2] = j.Position.Z;
                                var rotatedPoint = point.Multiply(this.rotationMatrix);

                                // Then shift them by the global coordinates.
                                shiftedPoint.X = (float)rotatedPoint[0, 0] + this.xOffset;
                                shiftedPoint.Y = (float)rotatedPoint[0, 1] + this.yOffset;
                                shiftedPoint.Z = (float)rotatedPoint[0, 2] + this.zOffset;
                                tempJoint.Position = shiftedPoint;

                                tempSkel.Joints[type] = tempJoint;
                            }
                            // Next, alter the higher-level parameters of our skeleton
                            SkeletonPoint shiftedPosition = new SkeletonPoint();
                            // Rotate
                            DenseMatrix p = new DenseMatrix(1, 3);
                            p[0, 0] = tempSkel.Position.X;
                            p[0, 1] = tempSkel.Position.Y;
                            p[0, 2] = tempSkel.Position.Z;
                            var rPoint = p.Multiply(this.rotationMatrix);

                            // Then shift them by the global coordinates.
                            shiftedPosition.X = (float)rPoint[0, 0] + this.xOffset;
                            shiftedPosition.Y = (float)rPoint[0, 1] + this.yOffset;
                            shiftedPosition.Z = (float)rPoint[0, 2] + this.zOffset;

                            tempSkel.Position = shiftedPosition;

                            // Now add that skeleton to our global skeleton list
                            this.globalSkeletons.Add(tempSkel);
                        }

                    }
                }
            }
开发者ID:AlanChatham,项目名称:002-Unintended-Consequences,代码行数:75,代码来源:MainWindow.xaml.cs


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