4

I'm currently trying to make a hand / finger tracking with a kinect in XNA. For this, I need to be able to specify the depth range I want my program to render. I've looked about, and I cannot see how this is done. As far as I can tell, kinect's depth values only work with pre-set ranged found in the depthStream.

What I would like to do is make it modular so that I can change the depth range my kinect renders. I know this has been down before but I can't find anything online that can show me how to do this.

Could someone please help me out?

I have made it possible to render the standard depth view with the kinect, and the method that I have made for converting the depth frame is as follows (I've a feeling its something in here I need to set)

  private byte[] ConvertDepthFrame(short[] depthFrame, DepthImageStream depthStream, int depthFrame32Length)
    {
        int tooNearDepth = depthStream.TooNearDepth;
        int tooFarDepth     = depthStream.TooFarDepth;
        int unknownDepth    = depthStream.UnknownDepth;
        byte[] depthFrame32 = new byte[depthFrame32Length];


        for (int i16 = 0, i32 = 0; i16 < depthFrame.Length && i32 < depthFrame32.Length; i16++, i32 += 4)
        {
            int player      = depthFrame[i16] & DepthImageFrame.PlayerIndexBitmask;
            int realDepth   = depthFrame[i16] >> DepthImageFrame.PlayerIndexBitmaskWidth;


            // transform 13-bit depth information into an 8-bit intensity appropriate
            // for display (we disregard information in most significant bit)
            byte intensity = (byte)(~(realDepth >> 8));


            if (player == 0 && realDepth == 00)
            {
                // white 
                depthFrame32[i32 + RedIndex]    = 255;
                depthFrame32[i32 + GreenIndex]  = 255;
                depthFrame32[i32 + BlueIndex]   = 255;
            }

         // omitted other if statements. Simple changed the color of the pixels if they went out of the pre=set depth values

            else
            {
                // tint the intensity by dividing by per-player values
                depthFrame32[i32 + RedIndex]    = (byte)(intensity >> IntensityShiftByPlayerR[player]);
                depthFrame32[i32 + GreenIndex]  = (byte)(intensity >> IntensityShiftByPlayerG[player]);
                depthFrame32[i32 + BlueIndex]   = (byte)(intensity >> IntensityShiftByPlayerB[player]);
            }
        }

        return depthFrame32;
    }

I have a strong hunch it's something I need to change in the int player and int realDepth values, but i can't be sure.

Patrick
  • 17,669
  • 6
  • 70
  • 85
N0xus
  • 2,674
  • 12
  • 65
  • 126
  • 1
    I'm not sure what are you trying to say by "kinect's depth values only work with pre-set ranged found in the depthStream". The kinect camera can sense depth between 1.2m to 3.5m (in the normal mode). The sensitivity of the depth has an 11-bit resolution (2048 values). – VladN Oct 02 '12 at 15:34
  • i think you are overcomplicating things. kinect gives you a depth for each pixel. the range this has is a hardware limitation. you can't adjust it. if you only want to look at objects in a smaller range then you just limit it yourself. i.e. if(depthFrame[i] > minD && depthFrame[i] < maxD){ //use this depth range between minD and maxD } – morishuz Jul 15 '13 at 12:36

1 Answers1

0

There is a new example in the Kinect for Windows Toolkit 1.8.0 called Adaptive UI-WPF. It deals with this directly in the Interaction zone viewer section. Take a look at the code for adjusting Near and Far Boundary. It should be helpful for your situation. .

IntStarFoo
  • 765
  • 8
  • 14