none
Distance Between user and The kinect Device RRS feed

  • Question

  • Hey all :)

    how to get the distance between user and the kinect ??

    i found a function but it's in kinect v1 

    public static double GetSkeletonDistance(this Skeleton skeleton)
            {
                return (skeleton.Position.* skeleton.Position.X) +
                       (skeleton.Position.* skeleton.Position.Y) +
                       (skeleton.Position.* skeleton.Position.Z);
            }
    

    i don't know how to make it under kinect v2 ?

    Friday, May 1, 2015 2:03 PM

Answers

  • The Z coordinate of the hips or chest should give you a good approximation of the distance of a user to the sensor.

    Brekel

    Friday, May 1, 2015 2:59 PM
    Moderator
  • Joint head = body.Joints[JointType.hipCentre];
    return head.Position.Z ;

    it always return 0 :/

    There is no hipCentre in Kinect v2 SDK. Have a look at JointType Enumeration. There you can see all the available JointTypes. I am using the SpineBase , because users may lean from time to time. So

    return body.Joints[JointType.SpineBase].Position.Z;

    should give you a nice distance. Keep in mind, that even the smallest changes will affect this value. So if you want to check for a distance, you might want to use a threshold or even joint accumulation.

    Best regards,

    Alex

    Edit: Please mark Brekel's answer as answer. Thanks.

    Saturday, May 2, 2015 8:48 AM

All replies

  • The Z coordinate of the hips or chest should give you a good approximation of the distance of a user to the sensor.

    Brekel

    Friday, May 1, 2015 2:59 PM
    Moderator
  • Joint head = body.Joints[JointType.hipCentre];
    return head.Position.Z ;

    it always return 0 :/
    Friday, May 1, 2015 3:50 PM
  • Joint head = body.Joints[JointType.hipCentre];
    return head.Position.Z ;

    it always return 0 :/

    There is no hipCentre in Kinect v2 SDK. Have a look at JointType Enumeration. There you can see all the available JointTypes. I am using the SpineBase , because users may lean from time to time. So

    return body.Joints[JointType.SpineBase].Position.Z;

    should give you a nice distance. Keep in mind, that even the smallest changes will affect this value. So if you want to check for a distance, you might want to use a threshold or even joint accumulation.

    Best regards,

    Alex

    Edit: Please mark Brekel's answer as answer. Thanks.

    Saturday, May 2, 2015 8:48 AM
  • Sorry for again hitting this question - as I am doing some calculations.

    For calculating distance traveled of SpineBase Z Position from one point to another, if I just subtract the values of both point then will it return me correct value? And moreover, what is the unit for returned result?

    I am very new to Kinect.

    Thanks!

    Friday, June 26, 2015 5:17 AM
  • Roughly, yes, but take into account that substracting two Z positions does not give you a real distance (as mathematically defined for a 3D space) only the variation in the Z axis. Depending on what you are looking for, this could be enough.

    Units for CameraSpacePoints are meters, so if you make newZPos - OldZPos and get 1.0 as a result, this means the user is one meter further from the sensor in the direction of the Z axis.


    • Edited by jmmroldan Friday, June 26, 2015 8:41 AM
    Friday, June 26, 2015 8:40 AM
  • Roughly, yes, but take into account that substracting two Z positions does not give you a real distance (as mathematically defined for a 3D space) only the variation in the Z axis. Depending on what you are looking for, this could be enough.

    Units for CameraSpacePoints are meters, so if you make newZPos - OldZPos and get 1.0 as a result, this means the user is one meter further from the sensor in the direction of the Z axis.



    Thanks buddy! Really helpful.
    Monday, July 6, 2015 1:31 PM