Search code examples
c#opencvkinectemgucvgesture-recognition

Recognize if an arm is swinging/moving towards Kinect sensor or away from it


I am trying to figure out how to recognize if a person's arm is swinging/moving towards or away from the Kinect. I'm thinking it is much like a hit or punch towards the sensor.

The depth changes as the arm is going toward or away from the sensor, but how can this gesture be recognized?

I'm using the Kinect for Windows (older version) and SDK 1.8. I have also looked at EMGU (C# wrapper for OpenCV).

Any help answering this question would be greatly appriciated.


Solution

  • You can check and use Tracking Users with Kinect Skeletal Tracking and Channel 9s tutorials.

    1 . Start with a base position of the user.

    enter image description here

    2 . Save the positions of the arm joints (e.g. schoulder left, elbow left, wrist left and hand left).

    3 . The saved positions of step 2 are your reference points. Use these to calculate a swing move (e.g. (handLeftNew.z-value < handLeftReference.z-value), so movement towards Kinect).

    Code sample

    // get the joint
    Joint leftHand = skeleton.Joints[JointType.HandLeft];
    
    // get the individual points of the left hand
    double lefttX = leftHand.Position.X;
    double leftY = leftHand.Position.Y;
    double leftZ = leftHand.Position.Z;