Kinect の深度データを画像 (Bgr565 形式) に変換しています。標準の for ループを使用して (色にマップするために) 深度ピクセルの配列を反復処理すると、滑らかな画像が得られます。しかし、Parallel.For を使用すると、画像がちらつきます。
コードセクションは次のとおりです。どんな助けでも大歓迎です:
// === Single-threaded depth to color conversion ===
for (int i = 0; i < depthPixelsArray.Length; ++i)
{
depth = (short)(depthPixelsArray[i] >> DepthImageFrame.PlayerIndexBitmaskWidth);
if (depth >= colorBoundary)
unchecked { colorPixelsArray[i] = (short)0xF800; }
else colorPixelsArray[i] = depth;
}
// === Multi-threaded depth to color conversion ===
Parallel.For (0, depthPixelsArray.Length, delegate(int i)
{
depth = (short)(depthPixelsArray[i] >> DepthImageFrame.PlayerIndexBitmaskWidth);
if (depth >= colorBoundary)
unchecked { colorPixelsArray[i] = (short)0xF800; }
else colorPixelsArray[i] = depth;
}
);