我正在进行一个小组项目,尝试在玩家(特别是玩家)靠近/远离时触发某些事件,因此我们编写了这个函数。(我们不允许使用骨骼功能)
private void FindDepth(DepthImageFrame depthFrame)
{
short[] rawDepthData = new short[depthFrame.PixelDataLength];
depthFrame.CopyPixelDataTo(rawDepthData);
Byte[] pixels = new byte[depthFrame.Height * depthFrame.Width * 4];
for (int depthIndex = 0; depthIndex < rawDepthData.Length; depthIndex++)
{
int player = rawDepthData[depthIndex] & DepthImageFrame.PlayerIndexBitmask;
int depth = rawDepthData[depthIndex] >> DepthImageFrame.PlayerIndexBitmaskWidth;
if (player > 0)
{
playerDepth = rawDepthData[depthIndex];
}
}
}
为什么通过抓取一个像素不能正确地获取玩家的深度?