public static WriteableBitmap ToWriteableBitmap(DepthImageSize viewDepthSize, ushort[] buff16) { // Create a temporal bitmap to save WriteableBitmap picture = new WriteableBitmap( viewDepthSize.Width, viewDepthSize.Height, 96.0, 96.0, PixelFormats.Gray16, null); // Copy array data into the writeable bitmap picture.Lock(); picture.WritePixels(new Int32Rect(0, 0, viewDepthSize.Width, viewDepthSize.Height), buff16, viewDepthSize.Width * 2, 0); picture.Unlock(); return(picture); }
//public ShapeProcessor() //{ //} //~ShapeProcessor() //{ //} // Threshold the depth data returning an array of markups public static byte[] HandThresholding(DepthImageSize _imageSize, int _col, int _row, int _th, ushort[] _frameDepth16) { byte[] mask8 = new byte[_frameDepth16.Length]; Array.Clear(mask8, 0, mask8.Length); int handDepth = _frameDepth16[_row * _imageSize.Width + _col]; int thUp = handDepth + _th; int thLow = handDepth - _th; for (int i = 0; i < _frameDepth16.Length; i++) { int valDepth = _frameDepth16[i]; if (valDepth > thLow && valDepth < thUp) { mask8[i] = 1; //255 } } return(mask8); }