コード例 #1
0
ファイル: ColorFrameBitmap.cs プロジェクト: tonyly/Kinect
 public ColorFrameBitmap(PlayColorFrame frame)
 {
     // force population of PixelFormat
     var data = frame.GetFrameDataAsync().Result;
     _bitmap = new WriteableBitmap(frame.Width, frame.Height, 96, 96, frame.Codec.PixelFormat, null);
     _bytes = new byte[_bitmap.PixelWidth * _bitmap.PixelHeight * (_bitmap.Format.BitsPerPixel / 8)];
     _dirtyRect = new Int32Rect(0, 0, frame.Width, frame.Height);
 }
コード例 #2
0
ファイル: ColorFrameBitmap.cs プロジェクト: tonyly/Kinect
 public void Update(PlayColorFrame frame)
 {
     if (frame != null)
     {
         frame.GetFrameDataAsync().ContinueWith(async (pixels) =>
         {
             await _bitmap.Dispatcher.InvokeAsync(() => {
                 _bitmap.FromByteArray(pixels.Result);
             });
         });
     }
 }
コード例 #3
0
ファイル: PlayColorFrame.cs プロジェクト: tonyly/Kinect
        internal static PlayColorFrame FromReader(BinaryReader reader, ICodec codec)
        {
            var frame = new PlayColorFrame();

            frame.FrameType = FrameTypes.Color;
            frame.RelativeTime = TimeSpan.FromMilliseconds(reader.ReadDouble());
            frame.FrameSize = reader.ReadInt64();

            long frameStartPos = reader.BaseStream.Position;

            frame.Codec = codec;
            frame.Codec.ReadColorHeader(reader, frame);

            frame.Stream = reader.BaseStream;
            frame.StreamPosition = frame.Stream.Position;
            frame.Stream.Position += frame.FrameDataSize;

            // Do Frame Integrity Check
            var isGoodFrame = false;
            try
            {
                if (reader.ReadString() == PlayFrame.EndOfFrameMarker)
                {
                    isGoodFrame = true;
                }
            }
            catch { }

            if (!isGoodFrame)
            {
                System.Diagnostics.Debug.WriteLine("BAD FRAME...RESETTING");
                reader.BaseStream.Position = frameStartPos + frame.FrameSize;

                try
                {
                    if (reader.ReadString() != PlayFrame.EndOfFrameMarker)
                    {
                        throw new IOException("The recording appears to be corrupt.");
                    }
                    return null;
                }
                catch
                {
                    throw new IOException("The recording appears to be corrupt.");
                }

            }

            return frame;
        }
コード例 #4
0
ファイル: KinectPlay.cs プロジェクト: tonyly/Kinect
 private void colorPlay_FrameArrived(PlayColorFrame frame)
 {
     if (ColorFrameArrived != null)
         ColorFrameArrived(this, new PlayFrameArrivedEventArgs<PlayColorFrame> { Frame = frame });
 }