private DepthFrame calcWallSensitive(DepthFrame depthFrame) { try { /*check each index of the received depth frame and * pull the image forward to the given wall sensitivity. * In this way, both noise will be removed.*/ ushort[] depthCurrent = new ushort[depthFrame.Width * depthFrame.Height]; depthFrame.CopyTo(depthCurrent); int x, y; for (int i = 0; i < depthCurrent.Length; i++) { x = i % depthFrame.Width; y = Convert.ToInt32(Math.Floor(Convert.ToDouble(i / depthFrame.Width))); if (depthCurrent[i] < 100 || depthCurrent[i] > (depthFrameResult[y] - (int)sldWallSense.Value)) { depthCurrent[i] = 0; } if (x < roiFrame.minX || x > roiFrame.maxX || y < roiFrame.minY || y > roiFrame.maxY) { depthCurrent[i] = 0; } } depthFrame.CopyFrom(depthCurrent); } catch (Exception ex) { MessageBox.Show(ex.Message); } return(depthFrame); }