Search code examples
c#windowskinectkinect-sdkgesture-recognition

What is the nature of XYZ cordinates of skeleton with kinect


I am developing a hand gesture application with kinect device . Here i am checking the gesture with X,y,z co-ordinates .

I want to know the nature of skeleton for a particular gesture . I am checking the gesture is hand push or not .

private handpush()
{

 bool MovedFront = false;
 float refDistance = 0.2F;


 SkeletonPoint refPos = SkeletonHistory[0].Joints[JointType.ShoulderCenter].Position;
 SkeletonPoint startPos = SkeletonHistory[0].Joints[JointType.HandRight].Position;

 //printing all intial cordinates

 Console.WriteLine(" ShoulderCenter[0].Z = " + refPos.Z);

 Console.WriteLine(" HandRight[0].X = " + startPos.X);
 Console.WriteLine(" HandRight[0].Y = " + startPos.Y);
 Console.WriteLine(" HandRight[0].Z = " + startPos.Z);


   for (int i = 20; i < SkeletonHistory.Count; i++)
   {
            Console.WriteLine(" ShoulderCenter[i].Z = " + SkeletonHistory[i].Joints[JointType.ShoulderCenter].Position.Z);
            Console.WriteLine(" HandRight[i].X = " + SkeletonHistory[i].Joints[JointType.HandRight].Position.X);
            Console.WriteLine(" HandRight[i].Y = " + SkeletonHistory[i].Joints[JointType.HandRight].Position.Y);
            Console.WriteLine(" HandRight[i].Z = " + SkeletonHistory[i].Joints[JointType.HandRight].Position.Z);


            if (!(SkeletonHistory[i].Joints[JointType.HandRight].Position.Y < SkeletonHistory[i].Joints[JointType.Head].Position.Y &&
                    Math.Abs(SkeletonHistory[i].Joints[JointType.ShoulderCenter].Position.Z - refPos.Z) < 0.05F &&
                    Math.Abs(SkeletonHistory[i].Joints[JointType.HandRight].Position.Y - startPos.Y) < 0.1F &&
                    Math.Abs(SkeletonHistory[i].Joints[JointType.HandRight].Position.X - startPos.X) < 0.1F))
            {
                Console.WriteLine("CheckHandPush breaking !!");
                break;
            }

            if (SkeletonHistory[i].Joints[JointType.HandRight].Position.Z <= (startPos.Z - refDistance))
            {
                Console.WriteLine("CheckHandPush sucess");
                bMovedFront = true;
                temp_SkeletonHistory.Clear();
            }
    }

   return MovedFront;
}

But i am getting intial values like :

output :

ShoulderCenter[0].Z = 1.246491
 HandRight[0].X = 0.1519185
 HandRight[0].Y = -0.2328865
 HandRight[0].Z = 1.014945

 ShoulderCenter[i].Z = 1.248788
 HandRight[i].X = 0.1397971
 HandRight[i].Y = -0.2452036
 HandRight[i].Z = 1.054223

 -----
 ShoulderCenter[0].Z = 1.26865
 HandRight[0].X = 0.1545139
 HandRight[0].Y = -0.3375102
 HandRight[0].Z = 1.057466

 ShoulderCenter[i].Z = 1.25049
 HandRight[i].X = 0.09602752
 HandRight[i].Y = -0.283217
 HandRight[i].Z = 1.150237


 ---

 ShoulderCenter[0].Z = 1.243356
 HandRight[0].X = 0.1406149
 HandRight[0].Y = -0.2458241
 HandRight[0].Z = 1.065399

 ShoulderCenter[i].Z = 1.250542
 HandRight[i].X = 0.1392216
 HandRight[i].Y = -0.2418006
 HandRight[i].Z = 1.046706

I am pushing my hand , so the Z axis should increase the value or decrease the value ? means the Z coordinate length is starting from kinect device or human body ?

Is this conditions fine for hand push ? Any suggestions ? can i get a sample code ??

Any useful links for x,y,z co-ordinate checking for hand push , hand pull ?

I am confused with the co-ordinate checking .


Solution

  • These values are in meters in the Kinect v2 "Camera Space" (There is a nice picture on the linked page):

    Camera space refers to the 3D coordinate system used by Kinect. The coordinate system is defined as follows:

    • The origin (x=0, y=0, z=0) is located at the center of the IR sensor on Kinect
    • X grows to the sensor’s left
    • Y grows up (note that this direction is based on the sensor’s tilt)
    • Z grows out in the direction the sensor is facing
    • 1 unit = 1 meter

    Therefore, when you stand in front of the camera and push your hand towards it, the Z value should decrease.
    To get coordinates based on the users position & direction, you'd have to rotate and translate the coordinates yourself.