本文整理匯總了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;
}