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


C# Body.Where方法代码示例

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


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

示例1: BodyReader_FrameArrived

        private void BodyReader_FrameArrived(object sender, BodyFrameArrivedEventArgs e)
        {
            using (var frame = e.FrameReference.AcquireFrame())
            {
                if (frame != null)
                {
                    Body[] bodies = new Body[frame.BodyCount];
                    frame.GetAndRefreshBodyData(bodies);

                    Body body = bodies.Where(b => b.IsTracked).FirstOrDefault();

                    if (!_faceSource.IsTrackingIdValid)
                    {
                        if (body != null)
                        {
                            _faceSource.TrackingId = body.TrackingId;
                        }
                    }
                }
            }
        }
开发者ID:ReallyRad,项目名称:kinect-2-face-hd,代码行数:21,代码来源:MainWindow.xaml.cs

示例2: bodyReader_FrameArrived

        private void bodyReader_FrameArrived(object sender, BodyFrameArrivedEventArgs e)
        {
            using (var frame = e.FrameReference.AcquireFrame())
            {
                if (frame != null)
                {
                    Wall.Clear();

                    var bodies = new Body[frame.BodyCount];
                    frame.GetAndRefreshBodyData(bodies);

                    foreach (var body in bodies.Where(b => b.IsTracked))
                    {
                        foreach (var joint in body.Joints.Select(j => j.Value))
                        {
                            Wall.DrawPoint(joint, Brushes.White);
                        }

                        //Serializer.Save(body);
                    }
                }
            }
        }
开发者ID:ngalin,项目名称:Illumimateys,代码行数:23,代码来源:Main.xaml.cs

示例3: MotionData

 /// <summary>
 /// コンストラクタ
 /// </summary>
 /// <param name="frameNo"></param>
 /// <param name="dataDir"></param>
 /// <param name="timeStamp"></param>
 /// <param name="bodies"></param>
 public MotionData(int frameNo, string dataDir, DateTime timeStamp, Body[] bodies, Dictionary<ulong, PointsPair> pointPairs)
 {
     this.FrameNo = frameNo;
     this.ImagePath = Path.Combine(dataDir, frameNo.ToString() + "_color.jpg");
     this.DepthPath = Path.Combine(dataDir, frameNo.ToString() + "_depth.png");
     this.UserPath = Path.Combine(dataDir, frameNo.ToString() + "_user.png");
     this.TimeStamp = timeStamp;
     this.bodies = bodies.Where(body => body.IsTracked).Select(body => new SerializableBody(body)).ToArray();
     foreach (SerializableBody body in this.bodies)
     {
         try
         {
             body.colorSpacePoints = pointPairs[body.TrackingId].Item1;
             body.depthSpacePoints = pointPairs[body.TrackingId].Item2;
         }catch(KeyNotFoundException e){                    
             body.colorSpacePoints = null;
             body.depthSpacePoints = null;
         }
     }
 }
开发者ID:guozanhua,项目名称:KinectMotionCapture,代码行数:27,代码来源:MotionDataHandler.cs

示例4: TrackBodies

        /// <summary>
        /// Manages Body Tracking Id by detecting when a body moves is front of an existing body and the existing body loses it's body
        /// </summary>
        /// <param name="bodies">The Kinect bodies collection</param>
        public void TrackBodies(Body[] bodies)
        {
            bool writeOutput = false;

            //if our body count hasn't changed just return null
            //we're doing this for performance
            //this could fail if someone quickly runs in front of a existing body or if an existing player leaves quickly and a new player enters quickly at the same time
            if (bodies.Where(b => b.IsTracked).Count() == TrackedKinectBodyCount)
            {
                CleanupMissingBodies();
                CleanupHijackedBodies();
                return;
            }

            #region debug output
            #if DEBUG
            {
                if (writeOutput)
                {
                    System.Diagnostics.Debug.Print("-------------------- Tracking Bodies ---------------------- ");

                    var trackedBodies = bodies.Where(b => b.IsTracked);
                    System.Diagnostics.Debug.Print("trackedBodies Count:{0}", trackedBodies.Count());
                    var ghostBodies = bodies.Where(b => b.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);
                    System.Diagnostics.Debug.Print("ghostBodies Count:{0}", ghostBodies.Count());
                }

                if (writeOutput && _trackedBodiesMissing != null && _trackedBodiesMissing.Count() > 0)
                {
                    foreach (var missingBody in _trackedBodiesMissing)
                    {
                        System.Diagnostics.Debug.Print("MissingBody Output - CorrelatedPlayerId:{0}, CurrentPlayerTrackingId:{1}, BodyPosition.X:{2}, BodyPosition.Y:{3}, BodyPosition.Z{4}, TimeWentMissing{5}",
                            missingBody.CorrelationPlayerId
                            , missingBody.CurrentPlayerTrackingId
                            , missingBody.BodyPosition.X
                            , missingBody.BodyPosition.Y
                            , missingBody.BodyPosition.Z
                            , missingBody.TimeWentMissing.ToString());

                        foreach (var trackingId in missingBody.PlayerTrackingIds)
                            System.Diagnostics.Debug.Print("MissingBody Output PlayerTrackingIds for CorrelatedPlayerID: {0} - {1}", missingBody.CorrelationPlayerId, trackingId);
                    }

                }
                else if (writeOutput)
                    System.Diagnostics.Debug.Print("MissingBody Output - there are no missing bodies ");

                if (writeOutput && bodies.Any(b => b.IsTracked) && _trackedBodies != null)
                {
                    foreach (var body in bodies.Where(b => b.IsTracked))
                        System.Diagnostics.Debug.Print("Body - IsTracked:{0}, TrackingId:{1}, X:{2}, Y:{3}, Z{4}", body.IsTracked, body.TrackingId, body.Joints[BodyPositionJoint].Position.X, body.Joints[BodyPositionJoint].Position.Y, body.Joints[BodyPositionJoint].Position.Z);

                    foreach (var tb in _trackedBodies)
                    {
                        System.Diagnostics.Debug.Print("TrackedBody - BodyIsTracked:{0}, BodyTrackingId:{1}, TrackedBodyCorrelatedPlayerId:{2}, TrackedBodyCurrentPlayerTrackingId:{3}, BodyX:{4}, BodyY:{5}, BodyZ{6}, TrackedBodyX:{7}, TrackedBodyY:{8}, TrackedBodyZ{9}"
                            , tb.Value.IsTracked
                            , tb.Value.TrackingId
                            , tb.Key.CorrelationPlayerId
                            , tb.Key.CurrentPlayerTrackingId
                            , tb.Value.Joints[BodyPositionJoint].Position.X
                            , tb.Value.Joints[BodyPositionJoint].Position.Y
                            , tb.Value.Joints[BodyPositionJoint].Position.Z
                            , tb.Key.BodyPosition.X
                            , tb.Key.BodyPosition.Y
                            , tb.Key.BodyPosition.Z);

                        foreach (var trackingId in tb.Key.PlayerTrackingIds)
                            System.Diagnostics.Debug.Print("PlayerTrackingIds for CorrelatedPlayerID: {0} - {1}", tb.Key.CorrelationPlayerId, trackingId);
                    }
                }
            }
            #endif //DEBUG
            #endregion debug output

            if (bodies != null && bodies.Length > 0)
            {
                //first time in, just add bodies to TrackedBodies collection
                if (_trackedBodies.Count() == 0)
                {
                    foreach (var body in bodies)
                    {
                        var trackedBody = new TrackedBody(this)
                        {
                            BodyPosition = body.Joints[BodyPositionJoint].Position,
                        };
                        trackedBody.PlayerTrackingIds.Add(body.TrackingId);
                        _trackedBodies.Add(trackedBody, body);
                    }
                }
//.........这里部分代码省略.........
开发者ID:jesjesd,项目名称:KAIT,代码行数:101,代码来源:BodyTrackingService.cs

示例5: SendBodyData

        void SendBodyData(ref UDP_PACKETS_CODER.UDP_PACKETS_ENCODER enc, Body[] bodies, int numberofplayer)
        {
            try
            {
                //UDP_PACKETS_CODER.UDP_PACKETS_ENCODER enc = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();
                List<string> str = new List<string>();

                str.Add(bodies.Length.ToString());
                byte MoP = (byte)bodies.Length;
                enc += MoP; //MaxofPlayer

                str.Add(numberofplayer.ToString());
                byte NoP = (byte)numberofplayer;
                enc += NoP; //NumberOfPlayer

                int NumberofBody = 0;
                int NumberofJoint = 0;
                foreach (var body in bodies.Where(b => b.IsTracked))
                {

                    NumberofBody++;
                    byte NoB = (byte)body.Joints.ToArray().Length;
                    enc += NoB;

                    foreach (var joint in body.Joints)
                    {
                        //kinect関節名前書き出し
                        str.Add(joint.Value.JointType.ToString());
                        NumberofJoint++;
                        str.Add(NumberofJoint.ToString());
                        enc += this.Dimension;
                        enc += joint.Value.Position.X;
                        enc += joint.Value.Position.Y;
                        enc += joint.Value.Position.Z;
                        //追加
                        enc += body.JointOrientations[joint.Value.JointType].Orientation.X;
                        enc += body.JointOrientations[joint.Value.JointType].Orientation.Y;
                        enc += body.JointOrientations[joint.Value.JointType].Orientation.Z;
                        enc += body.JointOrientations[joint.Value.JointType].Orientation.W;
                        byte TS = (byte)joint.Value.TrackingState;
                        enc += TS;

                        #region
                        str.Add(this.Dimension.ToString());
                        str.Add(joint.Value.Position.X.ToString());
                        str.Add(joint.Value.Position.Y.ToString());
                        str.Add(joint.Value.Position.Z.ToString());
                        str.Add(body.JointOrientations[joint.Value.JointType].Orientation.X.ToString());
                        str.Add(body.JointOrientations[joint.Value.JointType].Orientation.Y.ToString());
                        str.Add(body.JointOrientations[joint.Value.JointType].Orientation.Z.ToString());
                        str.Add(body.JointOrientations[joint.Value.JointType].Orientation.W.ToString());
                        str.Add(joint.Value.TrackingState.ToString());
                        #endregion
                    }
                }

                //byte[] data = enc.data;
                //csvに保存
                #region
                if (this.IsSave)
                {

                    //string s2 = string.Join(",", s1);
                    string strdata = string.Join(",", str.ToArray());
                    this.streamWriter.WriteLine(strdata);
                    //sw.Close();
                }
                #endregion
                //CIPCに送信
                /*
                #region
                if (this.cipcMain != null)
                {
                    this.cipcMain.send(data);
                }
                #endregion
                */
            }
            catch
            {
                this.ErrorPoint(System.Reflection.MethodBase.GetCurrentMethod().ToString());
            }
        }
开发者ID:tomokitejika,项目名称:ShadowMediaSystem,代码行数:83,代码来源:MainWindow.xaml.cs

示例6: BodyPosition

 //関節位置
 List<Joint> BodyPosition(Body[] bodies)
 {
     List<Joint> joints = new List<Joint>();
     //Point3f pt = new Point3f();
     int i = 0 ;
     foreach (var body in bodies.Where(b => b.IsTracked) )//
     {
         foreach (var joint in body.Joints)
         {
             if (joint.Value.JointType == JointType.SpineBase)
             {
                 //var position = this.kinect.CoordinateMapper.MapCameraPointToDepthSpace(joint.Value.Position);
                 //pt.X = joint.Value.Position.X;;
                 //pt.Y = joint.Value.Position.X;
                 //pt.Z = joint.Value.Position.X;
                 //Console.Write("hit\n");
                 joints.Add(joint.Value);
                 i++;
             }
         }
     }
     return joints;
 }
开发者ID:mahoo168,项目名称:mahoo,代码行数:24,代码来源:MakeShadowTest.cs

示例7: ChooseClosestBody

        /// <summary>
        /// ある点から一番近い人を追う
        /// </summary>
        /// <param name="bodies"></param>
        /// <param name="center"></param>
        /// <param name="closestDistance"></param>
        /// <returns></returns>
        private Body ChooseClosestBody( Body[] bodies,
            CameraSpacePoint center = new CameraSpacePoint(), float closestDistance = 2.0f )
        {
            Body closestBody = null;

            // 比較する関節位置
            var baseType = JointType.SpineBase;

            // 追跡しているBodyから選ぶ
            foreach ( var body in bodies.Where( b => b.IsTracked ) ) {
                // 比較する関節位置が追跡状態になければ対象外
                if ( body.Joints[baseType].TrackingState == TrackingState.NotTracked ) {
                    continue;
                }

                // 中心からの距離が近い人を選ぶ
                var distance = Distance( center, body.Joints[baseType].Position );
                if ( distance < closestDistance ) {
                    closestDistance = distance;
                    closestBody = body;
                }
            }

            return closestBody;
        }
开发者ID:noa99kee,项目名称:K4W2-Book,代码行数:32,代码来源:MainWindow.xaml.cs

示例8: BodyReader_FrameArrived

        private void BodyReader_FrameArrived(object sender, BodyFrameArrivedEventArgs e)
        {
            using (var frame = e.FrameReference.AcquireFrame())
            {
                if (frame != null)
                {
                    Body[] bodies = new Body[frame.BodyCount];
                    frame.GetAndRefreshBodyData(bodies);

                    Body body1 = bodies.Where(b => b.IsTracked).FirstOrDefault();
                    Body body2 = bodies.Where(b => b.IsTracked).LastOrDefault();

                    if (!_faceSource.IsTrackingIdValid)
                    {
                        if (body1 != null)
                        {
                            _faceSource.TrackingId = body1.TrackingId;
                        }
                    }
                    if (!_faceSourceSub.IsTrackingIdValid)
                    {
                        if (body2 != null)
                        {
                            if(_faceSource.TrackingId!=body2.TrackingId) _faceSourceSub.TrackingId = body2.TrackingId;
                            if (_faceSource.TrackingId != body1.TrackingId) _faceSourceSub.TrackingId = body1.TrackingId;
                        }
                    }
                    //MessageBox.Show(_faceSource.TrackingId.ToString() +"##"+ _faceSourceSub.TrackingId.ToString());
                }
            }
        }
开发者ID:yuukinona,项目名称:Facetrack,代码行数:31,代码来源:MainWindow.xaml.cs


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