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.
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()
{
private void KinectSensorOnAllFramesReady(object sender, AllFramesReadyEventArgs allFramesReadyEventArgs)
{
framesCounter = framesCounter++ % 2;
if (framesCounter == 0)
{
Skeleton first = GetFirstSkeleton(allFramesReadyEventArgs);
if (first == null)
{
txtP.Text = "No Person detected";
return;
}
if (first.TrackingState == SkeletonTrackingState.Tracked)
{
txtP.Text = "A person is detected";
save_joints(first);
}
}
}
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);
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