NuiImageStreamGetNextFrame(colorStreamHandle, 0, &colorFrame);
INuiFrameTexture *pTexture = colorFrame->pFrameTexture;
NUI_LOCKED_RECT LockedRect;
pTexture->LockRect(0, &LockedRect, NULL, 0);
if( LockedRect.Pitch != 0 )
{
for (int i=0; i<colorImage.rows; i++)
{
uchar *ptr = colorImage.ptr<uchar>(i);
uchar *pBuffer = (uchar*)(LockedRect.pBits) + i * LockedRect.Pitch;
for (int j=0; j<colorImage.cols; j++)
{
ptr[3*j] = pBuffer[4*j];
ptr[3*j+1] = pBuffer[4*j+1];
ptr[3*j+2] = pBuffer[4*j+2];
}
}
}
else
{
cout<<"捕捉色彩图像出现错误"<<endl;
}
pTexture->UnlockRect(0);
NuiImageStreamReleaseFrame(colorStreamHandle, colorFrame );
}
void getDepthImage(HANDLE &depthEvent, HANDLE &depthStreamHandle, Mat &depthImage)
{
const NUI_IMAGE_FRAME *depthFrame = NULL;
NuiImageStreamGetNextFrame(depthStreamHandle, 0, &depthFrame);
INuiFrameTexture *pTexture = depthFrame->pFrameTexture;
NUI_LOCKED_RECT LockedRect;
pTexture->LockRect(0, &LockedRect, NULL, 0);
RGBQUAD q;
if( LockedRect.Pitch != 0 )
{
for (int i=0; i<depthImage.rows; i++)
{
uchar *ptr = depthImage.ptr<uchar>(i);