本文整理汇总了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;
}