Search code examples
c++kinect-sdk

What is NUI_LOCKED_RECT and what does the Pitch represent? (kinect)


The documentation says: Defines the surface for a locked rectangle. I'm trying to understand this code.

What I understand so far:

Create an image frame; Get the texture interface of the image frame: (Represents an object containing image frame data that is similar to a Direct3D texture, but has only one level (does not support mipmapping).)

Lock the buffer for read and write access.

NUI_IMAGE_FRAME imageFrame;
NUI_LOCKED_RECT LockedRect;

INuiFrameTexture* texture = imageFrame.pFrameTexture;
texture->LockRect(0,&LockedRect,NULL,0);

    if (LockedRect.Pitch != 0)

What I don't understand is the process of locking a buffer for a INUIFrameTexture and I also don't understand what the LockedRect.Pitch means..


Solution

  • You have to lock the buffer because the kinect mustn't read/rewrite it, so move the buffer into a NUI_LOCKED_RECT. LockedRect.Pitch is the number of bytes of data in a row of your locked rect.