none
Limited Area Depth data

    Question

  • I had a area limited by RightHand position (X,Y) and +- reference distance, for X and Y is the same calcule.

    I just want to obtain distance in that area.

    The depth data is obtained How??

    I tryed:

    short[] rawDepthData = new short[depth.PixelDataLength];
                depth.CopyPixelDataTo(rawDepthData);
    
    for (int depthIndexX = (int)Math.Round(RightHandPX) - RefDistance; depthIndexX < (int)Math.Round(RightHandPX) + RefDistance; depthIndexX++)
                {
                    for (int depthIndexY = (int)Math.Round(RightHandPY) - RefDistance; depthIndexY < (int)Math.Round(RightHandPY) + RefDistance; depthIndexY++)
                    {
    
    int dist = rawDepthData[(depthIndexY + depthIndexX)] >> DepthImageFrame.PlayerIndexBitmaskWidth;
    
    
    ...
    RightHandPX is the position of right hand in pixel. RightHandPY is the same but for Y.
    Friday, May 4, 2012 4:14 PM

Answers

  • I think the formula you want is:

    int dist = rawDepthData[(depthIndexY * depth.Width) + depthIndexX] >> DepthImageFrame.PlayerIndexBitmaskWidth;

    John
    K4W Dev

    Friday, May 4, 2012 5:41 PM

All replies

  • I think the formula you want is:

    int dist = rawDepthData[(depthIndexY * depth.Width) + depthIndexX] >> DepthImageFrame.PlayerIndexBitmaskWidth;

    John
    K4W Dev

    Friday, May 4, 2012 5:41 PM
  • since you are dealing with an area of pixels, you need to average the range of all the pixels. Keep in mind to make sure your ranges don't go past the bounds of the array.

    int totalDistance = 0;

    int counter = 0;

    for(int y = refY - 5; y < refY + 5; y++)

        if( y < 0 || y > DepthImageHeight )
            continue;

        for(int x = refX - 5; x < refX + 5; x++)

           if (x < 0 || x > DepthImageWidth )
               continue;

    (if we are here the x,y is valid)
    totalDistance += rawDepthData[(y * (Width of Depthframe) + x)] >> DepthImageFrame.PlayerIndexBitmaskWidth;
    counter++;

        }

    }

    // calculate the average of the distances

    double avgDist = totalDistance / counter;




    Friday, May 4, 2012 5:49 PM
  • Thanks was it that i searching for.

    Give me your opinion/idea,

    I want to make a variable area arround the hand. That area must increase if the hand is closer and decrease if the hand are far.

    I already tried to make a reference distance that was the duble of the distance of wrist and the hand. but it was much irregular, because the wrist joint jumpo to much. i already try to calculate a function that change with the hand distance, but as i approach the hand (between 1m - 1.5m) the reason of increaze is greater than the reason of increase between 1.5m - 2m, and the area arround the hand is much greater than the hand if it was at 1m of distance, and is smaller than the hand if it was at 2m of distance.

    I want a variable area because i need to see pixel by pixel the distance, to calculate the hand area to check if it was open or close..

    Sorry about my English.

    Help me please.

    Monday, May 7, 2012 4:36 PM