ColorImageFrame cframe4 = _sensor.ColorStream.OpenNextFrame(0); DepthImageFrame dframe4 = _sensor.DepthStream.OpenNextFrame(0); byte[] pixeldata = new byte[cframe4.PixelDataLength]; cframe4.CopyPixelDataTo(pixeldata); int vx,vy; DepthImagePixel[] pixeldata4 = new DepthImagePixel[dframe4.PixelDataLength]; dframe4.CopyDepthImagePixelDataTo(pixeldata4); for (int y = 0; y < dframe4.Height; y++) { for (int x = 0; x < dframe4.Width; x++) { ColorImagePoint p = dframe4.MapToColorImagePoint(x, y, ColorImageFormat.RgbResolution640x480Fps30); vx = p.X; vy = p.Y; int d = pixeldata4[x + y * dframe4.Width].Depth; vx = Math.Max(0, Math.Min(vx, cframe4.Width - 2)); vy = Math.Max(0, Math.Min(vy, cframe4.Height - 2)); if (d > 500 && d < 2500) { pixeldata[(vx + vy * cframe4.Width) * cframe4.BytesPerPixel] &= 0xFF; } else { //not sure what to insert in order to blank out the pixels without any data. ANDing with 0x00 results in yellow colour mask on top of original image, but not blank image } } } Bitmap bmp = ByteToBitmap(pixeldata, cframe4.Width, cframe4.Height); image1.Source = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(bmp.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); bmp.Dispose();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)