none
Kinect (K4Win) Depth: polling for MinDepth and MaxDepth slows down application RRS feed

  • Question

  • I have setup a DepthImagePixel array and check if the depth is within min and max. 
    When I use   
     if (DepthImagePixel[i].IsKnownDepth) 
    inside the for loop the application runs fine but if I try to use   
    if (DepthImagePixel.Depth > DepthFrame.MinValue && DepthImagePixel.Depth < DepthFrame.MaxValue)
    the application freezes every couple of seconds. I took out all of the code to actually draw the image and replaced it line by line... that if statement bogs up the works. Further if I replace the call to DepthFrame.MinValue with 800 and DepthFrame.MaxValue with 4000 the application runs smooth again. Why is this call so slow? I understand that I am calling it over every pixel in the depth map but still this is boggling my mind as to why it is so ridiculously slow. 

    Anyone else having this problem? 
    Friday, October 19, 2012 1:51 AM

Answers

  • I had a similar issue, and I solved it by capturing the MinValue and MaxValue into a variable once per DepthFrame (outside of the loop that checks the pixels) and then doing my comparisons against the variable rather than calling the property every time.  I suspect these properties are actually calling a method under the covers that is deriving the min and max values on the fly, but I can't prove that.

    Walt Smith Senior Architect

    Friday, October 19, 2012 12:48 PM

All replies

  • I had a similar issue, and I solved it by capturing the MinValue and MaxValue into a variable once per DepthFrame (outside of the loop that checks the pixels) and then doing my comparisons against the variable rather than calling the property every time.  I suspect these properties are actually calling a method under the covers that is deriving the min and max values on the fly, but I can't prove that.

    Walt Smith Senior Architect

    Friday, October 19, 2012 12:48 PM
  • Thanks Walt, 

    This is what I figured as well. makes perfect sense. 

    Friday, October 19, 2012 12:50 PM