public void synchronize( ReplayDepthImageFrame depthFrame, ReplayColorImageFrame colorFrame, ReplaySkeletonFrame skletonFrame, Boolean isPauseMode ) { IsPauseMode = isPauseMode; colorFrame.CopyPixelDataTo(_colorByte); depthFrame.CopyPixelDataTo(_depthShort); for (int i = 0; i < _pixelDepthDataLength; i++) { _depthByte[i] = (byte)(_depthShort[i] * 0.064-1); } _isCreation = true; IsSkeletonDetected = skletonFrame.IsSkeletonDetected; if (skletonFrame.IsSkeletonDetected) { UserSkeleton[SkeletonDataType.RIGHT_HAND] = new Point( skletonFrame.RightHandPositionX, skletonFrame.RightHandPositionY ); UserSkeleton[SkeletonDataType.LEFT_HAND] = new Point( skletonFrame.LeftHandPositionX, skletonFrame.LeftHandPositionY ); UserSkeleton[SkeletonDataType.SPINE] = new Point( skletonFrame.SpinePositionX, skletonFrame.SpinePositionY ); } _isCreation = false; }
private void UpdateColorFrame(ReplayColorImageFrame frame) { var pixelData = new byte[frame.PixelDataLength]; frame.CopyPixelDataTo(pixelData); if (ImageSource == null) ImageSource = new WriteableBitmap(frame.Width, frame.Height, 96, 96, PixelFormats.Bgr32, null); var stride = frame.Width * PixelFormats.Bgr32.BitsPerPixel / 8; ImageSource.WritePixels(new Int32Rect(0, 0, frame.Width, frame.Height), pixelData, stride, 0); }
private void ProcessColorImageFrame(ReplayColorImageFrame colorImageFrame) { if(colorImageFrame==null) return; var pixelData = new byte[colorImageFrame.PixelDataLength]; colorImageFrame.CopyPixelDataTo(pixelData); if (ColorImageSource == null) ColorImageSource = new WriteableBitmap(colorImageFrame.Width, colorImageFrame.Height, 96, 96, PixelFormats.Bgr32, null); var stride = colorImageFrame.Width * PixelFormats.Bgr32.BitsPerPixel / 8; ColorImageSource.WritePixels(new Int32Rect(0, 0, colorImageFrame.Width, colorImageFrame.Height), pixelData, stride, 0); }
internal void AddFrames(BinaryReader reader) { //not the best of approaches - assuming that color frame is the 1st frame followed by depth and skeleton frame while (reader.BaseStream.Position < reader.BaseStream.Length) { var header = (FrameType)reader.ReadInt32(); switch (header) { case FrameType.Color: var colorFrame = new ReplayColorImageFrame(); colorFrame.CreateFromReader(reader); frames.Add(new ReplayAllFrames { ColorImageFrame = colorFrame }); break; case FrameType.Depth: var depthFrame = new ReplayDepthImageFrame(); depthFrame.CreateFromReader(reader); if (frames.Any()) frames.Last().DepthImageFrame = depthFrame; break; case FrameType.Skeletons: var skeletonFrame = new ReplaySkeletonFrame(); skeletonFrame.CreateFromReader(reader); if (frames.Any()) frames.Last().SkeletonFrame = skeletonFrame; break; } } }
private void UpdateColorFrame(ReplayColorImageFrame frame) { //System.Console.WriteLine("update color frame"); // var uri = new Uri("C:\\Users\\WenxuanZhou\\Desktop\\881856_475135009220488_407602784_o.jpg"); // img1.Source = new BitmapImage(uri); var pixelData = new byte[frame.PixelDataLength]; frame.CopyPixelDataTo(pixelData); //if (ImageSource == null) // ImageSource = new WriteableBitmap(frame.Width, frame.Height, 96, 96, // PixelFormats.Bgr32, null); var stride = frame.Width * PixelFormats.Bgr32.BitsPerPixel / 8; //ImageSource.WritePixels(new Int32Rect(0, 0, frame.Width, frame.Height), pixelData, stride, 0); img1.Source = BitmapSource.Create(frame.Width, frame.Height, 96, 96, PixelFormats.Bgr32, null, pixelData, stride); }