Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
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.

C#
private static float[][] JointTab = new float[20][];
        List<float> Hlist = new List<float>();
        List<double> WDlist = new List<double>();
        List<float> JlistX = new List<float>();
        List<float> JlistY = new List<float>();
        List<float> JlistZ = new List<float>();
        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)
                return;
            }

            if (first.TrackingState == SkeletonTrackingState.Tracked)
            {
                txtP.Text = "A person is detected";
                
                save_joints(first);
              

            }

         }
        }
 //************************************************************************************************************

        // Save and display joints coordinates

        //************************************************************************************************************
        /// <summary>
        /// method to save and display joints coordinates detected in a list
        /// </summary>
        /// <param name="first"></param>
        /// <returns></returns>
        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;
                JlistX.Add(jx);
                JlistY.Add(jy);
                JlistZ.Add(jz);
            }

            JlistX.Sort();
            JlistY.Sort();
            JlistZ.Sort();
           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));
            Hlist.Add(H);

            //WDlist.Add(WD);

            //***********************************************************************//
            //                                                                       //
            //                        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
Posted
Updated 10-Mar-15 0:49am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900