none
Slightly Better Depth Demonstration RRS feed

  • General discussion

  • There was no option to post code.

    Example Pic(On Skydrive Click to Enlarge)

    If you want a better idea of depth here is some code I wrote that gives a clearer visulisation. It also makes the fact there is a shadow a little clearer.

    It also assumes you have no friends.

    Modify SkeletalViewer(MainWindow.xaml.cs) found in the SDK Samples with

     void nui_DepthFrameReady(object sender, ImageFrameReadyEventArgs e)
     {
      PlanarImage Image = e.ImageFrame.Image;
      byte[] convertedDepthFrame = hackedConvertDepthFrame(Image.Bits);
    

    .....

    }

     

     Insert the follow procedure

     

     byte[] hackedConvertDepthFrame(byte[] depthFrame16)
     {
    
     int red = 0;
     int blue = 0;
     int green = 0;
    
     for (int i16 = 0, i32 = 0; i16 < depthFrame16.Length && i32 < depthFrame32.Length; i16 += 2, i32 += 4)
     {
     int player = depthFrame16[i16] & 0x07;
     int first = depthFrame16[i16 + 1] << 5 | depthFrame16[i16] >> 3;
     int second = depthFrame16[i16 + 1] >> 3 * 256;
    
     int depth = first + second;
    
     if (depth != 0)
     {
      blue = 0;
      red = 0;
    
      green = depth % 255;
    
      if (green < 85)
      {
      green = 255 - green;
      }
    
     }
     else
     {
      green = 125;
      red = 125;
      blue = 125;
     }
    
     switch (player)
     {
      case 0:
      depthFrame32[i32] = (byte) blue;
      depthFrame32[i32 + 1] = (byte)green;
      depthFrame32[i32 + 2] = (byte)red;
      break;
      default :
      depthFrame32[i32] = (byte) 255;
      depthFrame32[i32 + 1] = (byte)green;
      depthFrame32[i32 + 2] = (byte)red;
      break;
     }
     }
     return depthFrame32;
     }
    

     




    • Edited by ZLoserKing Saturday, July 9, 2011 12:15 PM Updated with Picture
    Saturday, July 9, 2011 9:44 AM

All replies