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


C# Body.Count方法代码示例

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


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

示例1: SetActivePlayer

        public ulong SetActivePlayer(Body[] kinectBodies)
        {
            //If we don't have an active player, set the closest player as the active player
            //if we do have an active player, set the active player to the closest player if the closest player is closer than the active player within our variance setting
            //else keep the active player as the active player
            //and
            //ignore bodies that look to be candidtes for missing or hijacked bodies
            //ignore ghost bodies - bodies that don't have a count of the head, neck, shoulders and wrist joints in a valid Tracked State
            if (kinectBodies != null && kinectBodies.Count() > 0)
            {
                var closestPlayer = from bodies in kinectBodies
                                    where bodies.IsTracked == true
                                        && bodies.Joints.Count(joint => joint.Key == JointType.Head && joint.Value.TrackingState == TrackingState.Tracked
                                                                || joint.Key == JointType.Neck && joint.Value.TrackingState == TrackingState.Tracked
                                                                || joint.Key == JointType.ShoulderLeft && joint.Value.TrackingState == TrackingState.Tracked
                                                                || joint.Key == JointType.ShoulderRight && joint.Value.TrackingState == TrackingState.Tracked
                                                                || joint.Key == JointType.ElbowLeft && joint.Value.TrackingState == TrackingState.Tracked
                                                                || joint.Key == JointType.ElbowRight && joint.Value.TrackingState == TrackingState.Tracked
                                                                || joint.Key == JointType.WristLeft && joint.Value.TrackingState == TrackingState.Tracked
                                                                || joint.Key == JointType.WristRight && joint.Value.TrackingState == TrackingState.Tracked) >= RequiredJointsTrackedCount
                                        && bodies.Joints[BodyPositionJoint].Position.X > LeftBodySelectionTrackLimit
                                        && bodies.Joints[BodyPositionJoint].Position.X < RightBodySelectionTrackLimit
                                        && !_trackedBodiesMissing.Any(tbMissing => tbMissing.BodyPosition.Z - bodies.Joints[BodyPositionJoint].Position.Z <= SwitchActiveBodyZPositionVariance)
                                        && !_trackedBodiesHijacked.Any(tbHijacked => tbHijacked.BodyPosition.Z - bodies.Joints[BodyPositionJoint].Position.Z <= SwitchActiveBodyZPositionVariance)
                                    orderby bodies.Joints[BodyPositionJoint].Position.Z
                                    select bodies;

                //Z Depth of 152.4 millimeters = 6 inches

                if ((closestPlayer.FirstOrDefault() != null && ActiveBodyId == 0)
                    || (closestPlayer.FirstOrDefault() != null && closestPlayer.First().TrackingId != ActiveBodyId && ActiveBody != null
                        && ActiveBody.Joints[BodyPositionJoint].Position.Z - closestPlayer.First().Joints[BodyPositionJoint].Position.Z >= SwitchActiveBodyZPositionVariance))
                {
                    ActiveBody = closestPlayer.FirstOrDefault();
                }
                else if (closestPlayer != null && closestPlayer.Count() == 0)
                {
                    ActiveBody = null;
                }

                //System.Diagnostics.Debug.Print("GetNextPlayer returned ActiveBodyId: {0}", ActiveBodyId);

                return ActiveBodyId;
            }
            return 0;
        }
开发者ID:jesjesd,项目名称:KAIT,代码行数:46,代码来源:BodyTrackingService.cs


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