Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8829921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:56:49+00:00 2026-06-14T07:56:49+00:00

I use the following c++ code to read out the depth information from the

  • 0

I use the following c++ code to read out the depth information from the kinect:

    BYTE * rgbrun = m_depthRGBX;
    const USHORT * pBufferRun = (const USHORT *)LockedRect.pBits;

    // end pixel is start + width*height - 1
    const USHORT * pBufferEnd = pBufferRun + (Width * Height);

    // process data for display in main window.
    while ( pBufferRun < pBufferEnd )
    {
        // discard the portion of the depth that contains only the player index
        USHORT depth = NuiDepthPixelToDepth(*pBufferRun);

        BYTE intensity = static_cast<BYTE>(depth % 256);


        // Write out blue byte
        *(rgbrun++) = intensity;

        // Write out green byte
        *(rgbrun++) = intensity;

        // Write out red byte
        *(rgbrun++) = intensity;

        ++rgbrun;

        ++pBufferRun;

    }

What I’d like to know is, what is the easiest way to implement frame flipping (horizontal & vertical)? I couldn’t find any function in the kinect SDK, but maybe I missed it?

EDIT1 I’d like to not having to use any external libraries, so any solutions that explain the depth data layout and how to invert rows / columns, is highly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T07:56:50+00:00Added an answer on June 14, 2026 at 7:56 am

    So, you’re using a standard 16bpp single channel depth map with player data. This is a nice easy format to work with. An image buffer is arranged row-wise, and each pixel in the image data has the bottom 3 bits set to the player ID and the top 13 bits set to depth data.

    Here’s a quick’n’dirty way to read each row in reverse, and write it out to an RGBWhatever image with a simple depth visualisation that’s a little nicer to look at that the wrapping output you currently use.

    BYTE * rgbrun = m_depthRGBX;
    const USHORT * pBufferRun = (const USHORT *)LockedRect.pBits;
    
    for (unsigned int y = 0; y < Height; y++)
    {
        for (unsigned int x = 0; x < Width; x++)
        {
            // shift off the player bits
            USHORT depthIn = pBufferRun[(y * Width) + (Width - 1 - x)] >> 3;
    
            // valid depth is (generally) in the range 0 to 4095.
            // here's a simple visualisation to do a greyscale mapping, with white
            // being closest. Set 0 (invalid pixel) to black.
            BYTE intensity = 
                depthIn == 0 || depthIn > 4095 ?
                    0 : 255 - (BYTE)(((float)depthIn / 4095.0f) * 255.0f);
    
            *(rgbrun++) = intensity;
            *(rgbrun++) = intensity;
            *(rgbrun++) = intensity;
            ++rgbrun;
        }
    }
    

    Code untested, E&OE, etc 😉

    It is possible to parallelise the outer loop, if instead of using a single rgbrun pointer you get a pointer to the beginning of the current row and write the output to that instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use the following block of code to read lines out of a file
I use the following code (from Bluetooth Chat sample app) to read the incoming
I'm trying to use the following code of java to read image data on
I have the following code that read input from txt file as follow Paris,Juli,5,3,6
I would like to use to read properties file from out side of the
I use TIdTCPServer and the following code to read client input : repeat cl3:=cl3+AContext.Connection.IOHandler.ReadLnSplit(WasSplit,#0,-1,-1,TEncoding.UTF8);
I want to read unread messages from yahoo mail.so i used following code but
If I don't use strict; the following code works fine and prints out alice:
I am trying to use following code to read a Google text document. But
I use following code to store data in an array, then print it out.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.