none
Displaying depth value RRS feed

  • Question

  • Thanks your sharing firstly.I also want to combine depth data with the color color camera to display a colored CD image using openGL. I want to get the points clounds X,Y,Z and the R,G,B corresponding.According to what you said above ,I don't get what I want, X,Y,Z are bigger than 0xfff.Besides,R,G,B can't be gotten.

    why divide 255.0f?I use kinect windows SDK 1.6.If it is convenient to you,you can contact with me. QQ: 526157396

    My code paste below.Thank you for your time and your attention.

    void collectdata(long &d)

    {

    HRESULT hr;
    long& degree = d;
    HANDLE h1 =CreateEvent(NULL,TRUE,FALSE,NULL);
    HANDLE m_pDepthStreamHandle = NULL;
    HANDLE h3 = CreateEvent(NULL,TRUE,FALSE,NULL);
    HANDLE m_pVideoStreamHandle = NULL;
    hr= NuiImageStreamOpen(NUI_IMAGE_TYPE_COLOR,NUI_IMAGE_RESOLUTION_640x480,0,2,h1,&m_pDepthStreamHandle);
    hr= NuiImageStreamOpen(NUI_IMAGE_TYPE_DEPTH,NUI_IMAGE_RESOLUTION_640x480,0,2,h3,&m_pVideoStreamHandle);
    if(labs(degree)%ANGLE==0)
    {
    const NUI_IMAGE_FRAME *pImageFrame1 = NULL;
    const NUI_IMAGE_FRAME *pImageFrame2 = NULL;
    if(WaitForSingleObject(h1,INFINITE)==WAIT_OBJECT_0&&WaitForSingleObject(h3,INFINITE)==WAIT_OBJECT_0);
    {
    hr = NuiImageStreamGetNextFrame(m_pDepthStreamHandle,0,&pImageFrame1);
    hr = NuiImageStreamGetNextFrame(m_pVideoStreamHandle,0,&pImageFrame2);
    if(S_OK==hr)
    {
    INuiFrameTexture *pTexture2 = pImageFrame2->pFrameTexture;
    NUI_LOCKED_RECT lockrect2;
    pTexture2->LockRect(0,&lockrect2,NULL,0);
    if(lockrect2.Pitch!=0)
    {
    KinectPoint temp;
    long colorx,colory;
    for(int i=0;i<480;i++)
    {
    byte *pBuffer = (byte*)lockrect2.pBits;
    USHORT *pBufferRun = (USHORT*)pBuffer;
    for(int j=0;j<640;j++)
    {
    Vector4 v = NuiTransformDepthImageToSkeleton(j/640.0f,i/480.0f,*pBufferRun<<3);
    temp.x = v.x;
    temp.y = v.y;
    temp.z = -v.z;
    NuiImageGetColorPixelCoordinatesFromDepthPixel(NUI_IMAGE_RESOLUTION_640x480,0,j/2,i/2,*pBufferRun<<3,&colorx,&colory);

    int a = (colorx+(colory-1)*640)*4;
    temp.R = pBuffer[a+2];
    temp.G = pBuffer[a+1];
    temp.B = pBuffer[a];

    pBufferRun++;
    VectorPointClouds.push_back(temp);
    }
    }
    }
    }
    }
    NuiImageStreamReleaseFrame(m_pDepthStreamHandle,pImageFrame1);
    NuiImageStreamReleaseFrame( m_pVideoStreamHandle, pImageFrame2);
    }

    }

    <input id="465c7cf6-67bf-47cd-931f-abd326508c9b_attachments" type="hidden" />
    Saturday, November 24, 2012 1:16 AM

All replies

  • Review the SDK depth samples as these show samples of how you might visualize the depth data. Since the Kinect for Windows SDK only provide the depth value as a distance, it would require you to convert this value to something that would be useable in your application.
    Thursday, November 29, 2012 12:47 AM