Copy cropped image with RGB format directly from the kinect RRS feed

  • Question

  • When I try to copy cropped image to my byte array using colorFrame.LockRawImageBuffer() I get it as yuy2 format.

    Is there way to copy the cropped data as RGB (without of copping all the frame from the kinect)?

    I would appreciate any advice

    • Edited by TTroyAA Thursday, June 4, 2015 6:51 AM
    Thursday, June 4, 2015 6:51 AM


  • Locking the image buffer will always give you a YUY2 buffer. If you want RGBA, you will have to use CopyConvertedFrameDataToArray with the image format RGBA and an array of size 1920 * 1080 * 4.

    If you want a cropped image, you will have to copy the desired segment of data from this buffer, or use a source rectangle when rendering the texture:

    D2D_RECT_F dstRect;
    dstRect.left = 0;
    dstRect.right = 640; = 0;
    dstRect.bottom = 480;
    D2D_RECT_F sourceRect;
    dstRect.left = 50;
    dstRect.right = 150; = 0;
    dstRect.bottom = 300;

    If you just want a buffer of RGB, you would have to iterate over the array and discard the Alpha value.  However, this will be slow, so I would recommend just using the RGBA array and ignoring the Alpha value in your rendering logic.

    Thursday, June 4, 2015 7:24 AM