私は Kinect センサーを使用しており、深度とカラー フレームを調整して、互いに「適合する」画像として保存できるようにしています。私は msdn フォーラムと Kinect SDK のささやかなドキュメントに多くの時間を費やしてきましたが、どこにも行き着きません。
この回答に基づく: Kinect: Converting from RGB Coordinates to Depth Coordinates
私は次の関数を持っています。depthData
とcolorData
はから取得されNUI_LOCKED_RECT.pBits
、mappedData
は深度座標にマッピングされた新しいカラー フレームを含む出力です。
bool mapColorFrameToDepthFrame(unsigned char *depthData, unsigned char* colorData, unsigned char* mappedData)
{
INuiCoordinateMapper* coordMapper;
// Get coordinate mapper
m_pSensor->NuiGetCoordinateMapper(&coordMapper);
NUI_DEPTH_IMAGE_POINT* depthPoints = new NUI_DEPTH_IMAGE_POINT[640 * 480];
HRESULT result = coordMapper->MapColorFrameToDepthFrame(NUI_IMAGE_TYPE_COLOR, NUI_IMAGE_RESOLUTION_640x480, NUI_IMAGE_RESOLUTION_640x480, 640 * 480, reinterpret_cast<NUI_DEPTH_IMAGE_PIXEL*>(depthData), 640 * 480, depthPoints);
if (FAILED(result))
{
return false;
}
int pos = 0;
int* colorRun = reinterpret_cast<int*>(colorData);
int* mappedRun = reinterpret_cast<int*>(mappedData);
// For each pixel of new color frame
for (int i = 0; i < 640 * 480; ++i)
{
// Find the corresponding pixel in original color frame from depthPoints
pos = (depthPoints[i].y * 640) + depthPoints[i].x;
// Set pixel value if it's within frame boundaries
if (pos < 640 * 480)
{
mappedRun[i] = colorRun[pos];
}
}
return true;
}
このコードを実行したときに得られるのは、depthFrame に情報がなかったすべてのピクセルが削除された (白の) 変更されていないカラー フレームだけです。