none
Calculating the center of mass for skeleton ? RRS feed

  • General discussion

  • I am working on Kinect for my research project . I have worked previously to calculate the joint angle of kinect and the joint coordinates. I would like to calculate the center of mass of the body which is being tracked. 
    Any idea would be appreciated and code snippets would be immensely helpful.
    I owe a lot to stack overflow without the community help it would had not been possible to do such a thing.
    Thanks in Advance 
    Please find the code where i want to include this center of mass function. This function tracks the skeleton.
     
    Skeleton GetFirstSkeleton(AllFramesReadyEventArgs e)
            {
                using (SkeletonFrame skeletonFrameData = e.OpenSkeletonFrame())
                {
                    if (skeletonFrameData == null)
                    {
                        return null;
                    }


                    skeletonFrameData.CopySkeletonDataTo(allSkeletons);

                    //get the first tracked skeleton
                    Skeleton first = (from s in allSkeletons
                                      where s.TrackingState == SkeletonTrackingState.Tracked
                                      select s).FirstOrDefault();
                    return first;
                }


    I have tried using this code in my code but its not getting accustomed , can any one please help me include the center of mass code.

    oreach (SkeletonData data in skeletonFrame.Skeletons) {

     

      SkeletonFrame allskeleton = e.SkeletonFrame;

                    // Count passive and active person up to six in the group  

                    int numberOfSkeletonsT = (from s in allskeleton.Skeletons

                                              where s.TrackingState == SkeletonTrackingState.Tracked  select s).Count();

                    int numberOfSkeletonsP = (from s in allskeleton.Skeletons  

    where s.TrackingState == SkeletonTrackingState.PositionOnly select s).Count();

                    // Count passive and active person up to six in the group

                    int totalSkeletons = numberOfSkeletonsP + numberOfSkeletonsT;

                    //Console.WriteLine("TotalSkeletons = " + totalSkeletons);

     

     

    //======================================================

     if (data.TrackingState == SkeletonTrackingState.PositionOnly)

                    {

    foreach (Joint joint in data.Joints)

                        {

                            if (joint.Position.Z != 0)

                            {

        double centerofmassX = com.Position.X;

                                double centerofmassY = com.Position.Y;

                                double centerofmassZ = com.Position.Z;

           Console.WriteLine( centerofmassX +  centerofmassY + centerofmassZ );

                            }

                    }

    Listen , Smile , Agree, And Then Do whatever the Fuck you were gonna do AnyWay

    Sunday, February 23, 2014 9:22 PM

All replies

  • First of all could you explain if you really need the center of mass (really taking into account the spatial distribution of mass) or if you need a central position of the body?

    In the code snippet you pasted you are printing joint positions for each joint, but only if the position of the skeleton is tracked. This does not make sense since joint data will be invalid if only the skeleton position is tracked.

    The SkeletonTrackingState.PositionOnly is the transition state between a fully tracked and non-tracked person. The Position stored in the Skeleton data is the value to use in this case.

    kind regards,

    Roland Smeenk

    Monday, February 24, 2014 8:17 AM
  • Hi Roland , 
    Thank you for your response.

    I need to calculate the center of mass of the body which I am tracking. No I do not need the central psoition of body. Center of mass would enable me to find the center of pressure.

    Yes presently I am calculating the joints angles for the skeleton which is being tracked.

    Do you have any idea how can I calculate the COM for the skeleton which is being tracked.

    I know the position only is used to calculate the COM with w . So I want to know how can I include in my code and what changes need to be done.

    Please help.

    Regards

    Afzal khan


    Listen , Smile , Agree, And Then Do whatever the Fuck you were gonna do AnyWay

    Monday, February 24, 2014 8:50 AM
  • To calculate the COM you could make an estimate for the center of mass for each joint and then take the average weighted by their relative part in the total mass. I think you can estimate the mass and COM for each joint based on antropometric data. I can imagine that the joint length could be of use to improve the mass estimate for each joint.

    Hope this helps.

    --
    Roland

    Monday, February 24, 2014 9:54 PM
  • Thanks for the reply Roland, 

    Still the question is how can I include it in my code . The present status of my code is that Kinect is able to track the skeleton. But how can I inculde the COM function in the existing code . Can you please guide me for including the code.

    Regards

    Afzal


    Listen , Smile , Agree, And Then Do whatever the Fuck you were gonna do AnyWay

    Tuesday, February 25, 2014 7:44 AM
  • Hi Afzal,

    I've not written code to calculate the COM before so you will have to write it yourself.

    --
    Roland

    Tuesday, February 25, 2014 8:15 AM
  • Thank you Roland for your response. I will try to write the code and when it works I will upload it here .

    Hope so someone who has written COM code responses to this query.

    Regards

    Afzal 


    Listen , Smile , Agree, And Then Do whatever the Fuck you were gonna do AnyWay

    Tuesday, February 25, 2014 10:03 AM
  • Hello Afzal,

    Does your code works? I'm interested for this calculation, could you upload your code here?

    Thank you

    Haishan

    Wednesday, April 22, 2015 8:56 AM