private void Kinect_DepthFrameReady(object sender, DepthImageFrameReadyEventArgs e) { using (DepthImageFrame depthFrame = e.OpenDepthImageFrame()) { if (depthFrame != null) { Bitmap DepthBitmap = new Bitmap(depthFrame.Width, depthFrame.Height, PixelFormat.Format32bppRgb); if (_depthPixels.Length != depthFrame.PixelDataLength) { _depthPixels = new DepthImagePixel[depthFrame.PixelDataLength]; _mappedDepthLocations = new ColorImagePoint[depthFrame.PixelDataLength]; } //Copy the depth frame data onto the bitmap var _pixelData = new short[depthFrame.PixelDataLength]; depthFrame.CopyPixelDataTo(_pixelData); BitmapData bmapdata = DepthBitmap.LockBits(new Rectangle(0, 0, depthFrame.Width, depthFrame.Height), ImageLockMode.WriteOnly, DepthBitmap.PixelFormat); IntPtr ptr = bmapdata.Scan0; Marshal.Copy(_pixelData, 0, ptr, depthFrame.Width * depthFrame.Height); DepthBitmap.UnlockBits(bmapdata); pictureBox.Image = DepthBitmap; } // sensor.CoordinateMapper.MapDepthFrameToColorFrame(DepthImageFormat.Resolution640x480Fps30,_depthPixels,ColorImageFormat.RgbResolution640x480Fps30,_mappedDepthLocations); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)