Microsoft.Samples.Kinect.RecordAndPlaybackBasics.KinectBodyView.Reader_BodyFrameArrived C# (CSharp) Метод

Reader_BodyFrameArrived() приватный Метод

Handles the body frame data arriving from the sensor and updates the associated gesture detector object for each body
private Reader_BodyFrameArrived ( object sender, BodyFrameArrivedEventArgs e ) : void
sender object object sending the event
e BodyFrameArrivedEventArgs event arguments
Результат void
        private void Reader_BodyFrameArrived(object sender, BodyFrameArrivedEventArgs e)
        {
            bool dataReceived = false;

            using (BodyFrame bodyFrame = e.FrameReference.AcquireFrame())
            {
                if (bodyFrame != null)
                {
                    if (this.bodies == null)
                    {
                        // creates an array of 6 bodies, which is the max number of bodies that Kinect can track simultaneously
                        this.bodies = new Body[bodyFrame.BodyCount];
                    }

                    // The first time GetAndRefreshBodyData is called, Kinect will allocate each Body in the array.
                    // As long as those body objects are not disposed and not set to null in the array,
                    // those body objects will be re-used.
                    bodyFrame.GetAndRefreshBodyData(this.bodies);
                    dataReceived = true;
                }
            }

            if (dataReceived)
            {
                // visualize the new body data
                this.UpdateBodyFrame(this.bodies);
            }
        }