Ejemplo n.º 1
0
        private void HandleColorFrame(ColorFrameReference reference)
        {
            if (Task.StandBy)
            {
                ColorWatch.Reset(); return;
            }

            ColorWatch.Again();
            using (var frame = reference.AcquireFrame()) {
                if (frame == null)
                {
                    return;
                }

                // Copy data to array based on image format
                if (frame.RawColorImageFormat == ColorImageFormat.Bgra)
                {
                    frame.CopyRawFrameDataToArray(Color.Pixels);
                }
                else
                {
                    frame.CopyConvertedFrameDataToArray(Color.Pixels, ColorImageFormat.Bgra);
                }

                Color.Stamp.Time = System.DateTime.Now;
            }
            ColorWatch.Stop();
        }
Ejemplo n.º 2
0
        private void HandleBodyIndexFrame(BodyIndexFrameReference reference)
        {
            if (Task.StandBy)
            {
                BodyIndexWatch.Reset(); return;
            }

            BodyIndexWatch.Again();
            using (var frame = reference.AcquireFrame()) {
                if (frame == null)
                {
                    return;
                }

                frame.CopyFrameDataToArray(BodyIndex.Pixels);

                /*
                 * using (Microsoft.Kinect.KinectBuffer buffer = indexFrame.LockImageBuffer()) {
                 * IntPtr ptr = buffer.UnderlyingBuffer;
                 * RefreshBodyArea(ptr, buffer.Size);
                 * }
                 */
                BodyIndex.Stamp.Time = System.DateTime.Now;
            }
            BodyIndexWatch.Stop();
        }
Ejemplo n.º 3
0
        private void HandleInfraredFrame(InfraredFrameReference reference)
        {
            if (Task.StandBy)
            {
                InfraredWatch.Reset(); return;
            }

            InfraredWatch.Again();
            using (var frame = reference.AcquireFrame()) {
                if (frame == null)
                {
                    return;
                }

                frame.CopyFrameDataToArray(Infrared.Pixels);
                Infrared.Stamp.Time = System.DateTime.Now;
            }
            InfraredWatch.Stop();
        }
Ejemplo n.º 4
0
        private void HandleBodyFrame(BodyFrameReference reference)
        {
            if (Task.StandBy)
            {
                BodyWatch.Reset(); return;
            }

            BodyWatch.Again();
            using (var frame = reference.AcquireFrame()) {
                if (frame == null)
                {
                    return;
                }

                // 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.
                var tmp = (IList <Body>)Body.RawData;
                frame.GetAndRefreshBodyData(tmp);
                Body.Stamp.Time = System.DateTime.Now;
                RefreshBodyData(Body);
            }
            BodyWatch.Stop();
        }