Depht data on opengl texture RRS feed

  • Question

  • Hi!

    I'm trying to set depht data on opengl texture using glTexImage2D, but I can't see the texture well. My code to get depht data is a copy of sdk SkeletalViewer sample...


    void KinectNuiControl::Nui_GotDepthAlert( )
     const NUI_IMAGE_FRAME * pImageFrame = NULL;
     HRESULT hr = NuiImageStreamGetNextFrame(
      &pImageFrame );
     if( FAILED( hr ) )
     NuiImageBuffer * pTexture = pImageFrame->pFrameTexture;
     pTexture->LockRect( 0, &LockedRect, NULL, 0 );
     if( LockedRect.Pitch != 0 )
      BYTE * pBuffer = (BYTE*) LockedRect.pBits;
      // draw the bits to the bitmap
      RGBQUAD * rgbrun = m_rgbWk;
      USHORT * pBufferRun = (USHORT*) pBuffer;
      for( int y = 0 ; y < 240 ; y++ )
       for( int x = 0 ; x < 320 ; x++ )
        RGBQUAD quad = Nui_ShortToQuad_Depth( *pBufferRun );
        *rgbrun = quad;
      //m_DrawDepth.DrawFrame( (BYTE*) m_rgbWk );
      printf("Buffer length of received texture is bogus\r\n" );
     NuiImageStreamReleaseFrame( m_pDepthStreamHandle, pImageFrame );


    And I use (BYTE*) m_rgbWk to switch the data...

    void glTexImage2D(GLenum <var>target</var>,
     GLint <var>level</var>,
     GLint <var>internalformat</var>, //GL_RGB
     GLsizei <var>width</var>,
     GLsizei <var>height</var>,
     GLint <var>border</var>,
     GLenum <var>format</var>, //GL_RGB
     GLenum <var>type</var>,  //GL_UNSIGNED_BYTE
     const GLvoid * <var>pixels</var>) // (BYTE*) m_rgbWk

    I've been trying different values ​​for the parameters but the results haven't been goods, so I guess the problem is in the data ... I can see the figure of the person ... but very badly...

    Any help please??

    Thursday, June 23, 2011 12:02 PM


  • What are your flags for nui initialization and opening stream? Are you trying to use depth stream instead of depth and player index stream? If so, you can't just use the sample code as is, since the bit format of depth stream vs depth and player index stream are different. In both cases, depth data is 12 out of the total 16 bits of data for each pixel, but on depth plus player index this information will be in bits 3-14 whereas in plain depth stream this information will be in bits 0-11.

    Hope this helps!

    I'm here to help
    Tuesday, June 28, 2011 5:56 PM