velocity of a joint between two frames RRS feed

  • Question

  • Hello, 

    I'm stack for along time in this problem and i will really appreciate if any one could help me in that. 

    I  asked many times in many forums, i've searched alot but no answer that really helped me.

    i'm developping an application where i have to calculate the velocity of a joint of skeleton body using vs c# 2012 and kinect sdk 1.7

    i have first to be sure of  the logic of things before asking this question so,

    if I understood correctly, the delta_time i'm looking for to calculate velocity, is not the duration of one frame (1/30s) but it must be calculated from two instants: 
    1- the instant when detecting and saving the "joint point" in the first frame 
    2- the instant when detecting and saving the same "joint point" in the next frame

    if it's not true, thank you for clarifying things.

    starting from this hypothesis, i wrote a code to :

    - detectiong a person

    - tracking the spine joint ==> if it's is tracked then saving its coordinates into a list (I reduced the work for the moment on the Y axis to simplify)

    - pick up the time when saving the coordinates 

    - increment the framecounter (initially equal to zero)

    - if the frame counter is > 1  calculate velocity ( x2 - x1)/(T2 - T1) and save it

    here is a piece of the code:

     System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch();
            double msNow;
            double msPast;
            double diff;
            TimeSpan currentTime;
            TimeSpan lastTime = new TimeSpan(0);

       List<double> Sylist = new List<double>();

    private int framecounter = 0;

    private void KinectSensorOnAllFramesReady(object sender, AllFramesReadyEventArgs allFramesReadyEventArgs) { Skeleton first = GetFirstSkeleton(allFramesReadyEventArgs); if (first == null) // if there is no skeleton { txtP.Text = "No person detected"; // (Idle mode) return; } else { txtP.Text = "A person is detected"; skeletonDetected = true; /// look if the person is totally detected find_coordinates(first); /******************************* * time computing * /*******************************/ currentTime = stopWatch.Elapsed; msNow = currentTime.Seconds * 1000 + currentTime.Milliseconds; if (lastTime.Ticks != 0) { msPast = lastTime.Seconds * 1000 + lastTime.Milliseconds; diff = msNow - msPast; } lastTime = currentTime; } //framecounter++; } void find_coordinates(Skeleton first) { //*modification 07052014 *****/ Joint Spine = first.Joints[JointType.Spine]; if (Spine.TrackingState == JointTrackingState.Tracked) { double Sy = Spine.Position.Y; /******************************* * time starting * /*******************************/ stopWatch.Start(); Sylist.Add(Sy); framecounter++; } else return; if (framecounter > 1) { double delta_Distance = Sylist[Sylist.Count] - Sylist[Sylist.Count - 1]; } }

    to be honnest, i dont really know how ti use timespan and stopwatch in this context ( i mean when there are frames to process many times/s) 

    i will be thankfull for any help !


    • Edited by pink192y Friday, May 9, 2014 12:26 PM
    Friday, May 9, 2014 12:24 PM

All replies