private void ParseDepthFrame(DepthImageFrame depthFrame) { short[] rawDepthData = new short[depthFrame.PixelDataLength]; depthFrame.CopyPixelDataTo(rawDepthData); int minDepth = DepthThreshold; int bestDepthIndex = -1; int minDepthIndex = (int)this.topLeft.Y * depthFrame.Width; int maxDepthIndex = (int)this.bottomRight.Y * depthFrame.Width; minDepthIndex = 0; maxDepthIndex = 479 * depthFrame.Width; Console.WriteLine(minDepthIndex + " " + depthFrame.Width); for (int depthIndex = minDepthIndex; depthIndex < maxDepthIndex; depthIndex++) {/* * // Skip this depth index if it's horizontally outside of our textile * int x_kinect = (int)((depthIndex) % depthFrame.Width); * * if (x_kinect < topLeft.X) { continue; } * else if (x_kinect > bottomRight.X) * { * //depthIndex += (depthFrame.Width - (int)(bottomRight.X - topLeft.X - 1)); * continue; * }*/ int depth = rawDepthData[depthIndex] >> DepthImageFrame.PlayerIndexBitmaskWidth; // Ignore invalid depth values if (depth == -1 || depth == 0) { continue; } if (depth < minDepth) { minDepth = depth; bestDepthIndex = depthIndex; } } // Draw if a touch was found if (bestDepthIndex >= 0) { Console.WriteLine("here"); if (!this.hasSetDepthThreshold) { this.DepthThreshold = minDepth - TextileSpacing; this.hasSetDepthThreshold = true; } else { soundController.StartMusic(); DrawPoint(depthFrame, bestDepthIndex, minDepth); gotTouch = true; } } else { if (gotTouch == true) { soundController.StopMusic(); drawController.SaveCanvas(); } gotTouch = false; } }