Jump to content

how can I add more gestures?


Willow

Recommended Posts

Hi ,

 

Currently the predefined gestures cannot be customized in the SDK, since adding each new gesture requires a lot effort.

 

However, if you are using skeleton mode on Windows, you can customize your gesture using the skeleton results. You can use the 3D skeleton positions to calcualte straight/folded states of each finger and determine gesture. For example, if all the fingers are folded, then it's a fist gesture.

 

A recommend way is to use the `ModelRenderer` script to get smoothed skeleton and calculate bending angle of each finger. Below is a sample code for calculate bending angle of each finger.

 

Note: Below code uses raw hand data for illustration purpose, you can change to use the bone objects in hand model for better result.

  // fingerIndex is 0-4, for thumb-tail  // result is in [0 (straight), 180 (folded)]  float GetFingerAngle(GestureResult hand, int fingerIndex) {    int startIndex = fingerIndex * 4 + 1;    Vector3 root = hand.points[startIndex];    Vector3 joint1 = hand.points[startIndex + 1];    Vector3 joint2 = hand.points[startIndex + 2];    Vector3 top = hand.points[startIndex + 3];     Vector3 vec1 = joint1 - root;    Vector3 vec2 = joint2 - joint1;    Vector3 vec3 = top - joint2;     float angle = Vector3.Angle(vec1, vec2) + Vector3.Angle(vec2, vec3);    return Mathf.Clamp(angle, 0, 180);  }
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...