Kinect application runs a moment then bugs RRS feed

  • Question

  • Hello, 
    I'm developping an application using Kinect SDK 1.7 where i want to implement a fall detection algorithm.
    based on the joints coordinates, i have to calculate the maximum and the minimum of all the joints to determinate the 2 dimensions(H and WD) of a 3D bounding Box.
    i start with reducing the frames rate to 15FPS (in the KinectSensorOnAllFramesReady event) and then process frames to save the joints coordinates and calculate H and WD.
    here is a peice of code of what i did.

    List Hlist = new List();
    List WDlist = new List();
    List JlistX = new List();
    List JlistY = new List();
    List JlistZ = new List();
    static int framesCounter = 0;
    public MainWindow()
    // other process
    private void KinectSensorOnAllFramesReady(object sender, AllFramesReadyEventArgs allFramesReadyEventArgs)
    framesCounter = framesCounter++ % 2; // 2 is the divisor to work with 15 FPS
    if (framesCounter == 0)
    // other process to manipulate depth images
    Skeleton first = GetFirstSkeleton(allFramesReadyEventArgs);
    if (first == null) // s'il n y pas de squeulette 
    txtP.Text = "No Person detected"; // Idle mode)
    if (first.TrackingState == SkeletonTrackingState.Tracked)
    txtP.Text = "A person is detected";
    // Save and display joints coordinates
    /// method to save and display joints coordinates detected in a list
    private void save_joints(Skeleton first)
    foreach (Joint joint in first.Joints)
    float jx = joint.Position.X;
    float jy = joint.Position.Y;
    float jz = joint.Position.Z;
    float xMin = JlistX[0];
    float xMax = JlistX[JlistX.Count - 1];
    float yMin = JlistY[0];
    float yMax = JlistY[JlistY.Count - 1];
    float zMin = JlistZ[0];
    float zMax = JlistZ[JlistZ.Count - 1];
    float W = System.Math.Abs(xMin - xMax);
    float H = System.Math.Abs(yMin - yMax);
    float D = System.Math.Abs(zMin - zMax);
    double WD = System.Math.Sqrt(Math.Pow(W, 2) + Math.Pow(D, 2));
    // //
    // display min et max //
    // //
    xmax.Text = xMax.ToString();
    ymax.Text = yMax.ToString();
    zmax.Text = zMax.ToString();
    xmin.Text = xMin.ToString();
    zmin.Text = zMin.ToString();
    ymin.Text = yMin.ToString();
    dimH.Text = H.ToString();
    dimWD.Text = WD.ToString();

    when running the code, there are mani problems:
    1/ zmin is always at 0 ..
    2/ the application runs a moment, i can see max and min values changing and then it stay fixed while i continue to move and make gestures.
    3/ Hlist has always one only value which i don't understand.
    Can anyone please help me ? 
    i'm stuck here for a while and can't see where is the error !
    thanks for any help


    Tuesday, March 10, 2015 10:45 AM

All replies

  • zmin is 0 because not all joints are tracked or have some quality measurement that might make sense. Joints can be occluded or inferred. Review the skeleton basics code to check various properties of the skeleton joint object.

    step through your code and closely analyze each joint and determine what values you are getting and whether these need to be included in your algorithm.

    Are you correctly following the pattern of copying the data and releasing frames. How many times is your function getting called. If you are only getting one frame from the runtime, that would be why you only have one entry.

    Carmine Sirignano - MSFT

    Tuesday, March 10, 2015 7:05 PM
  • Hello, 

    Thanks for your answer. I actually correct the mistake of Zmin value. It was at zero because the non tracked skeleton joints are set to 0 so it's normal to have zero as zmin but i fixed that with removing zero values in  JlistZ.

    My function is called every 3 frames with this code:

    static int framesCounter
    private void KinectSensorOnAllFramesReady(object sender, AllFramesReadyEventArgs allFramesReadyEventArgs)
    framesCounter = framesCounter % 3; // 3 is the divisor to work with 10 FPS
                if (framesCounter == 0)
          }   // end allframes ready method

    Althought i'm working with 10 FPS,  user interface does not bug but the max and min values remain the same after a while, do you know why ?  

    PS: I'm working with an i5 CPU à 3,2 GHz, VS 2012 and kinect SDK 1.7


    • Edited by pink192y Thursday, March 12, 2015 10:01 AM
    Thursday, March 12, 2015 9:59 AM
  • If the error is do to a draw issue, are your values valid for the region you are mapping to on-screen?

    Carmine Sirignano - MSFT

    Monday, March 16, 2015 7:32 PM