-
Notifications
You must be signed in to change notification settings - Fork 19
Skeleton Tracking
When skeleton tracking, the developer would pass in an array of skeletal joints (control points on the body), a callback, and an optional polling frequency to receive the callbacks.
For example:
nuimotion.startSkeletonListener( [
nuimotion.Joints.LEFT_HAND,
nuimotion.Joints.RIGHT_HAND ],
onSkeletonUpdate /* , 50 (the default) */ );
Here, we start listening for the right and left hand. Our callback method is "onSkeletonUpdate". We'll receive our callback every 50 milliseconds by default. Passing in an alternate integer will set a different number of milliseconds. I've found that 50 works fairly well. A websocket connection on my local machine to my browser deals seems to work at 50ms. Anything less than 50, do at your own risk. Anything higher may be good to test out especially if you are not working locally.
A complete list of joints you can listen for is as follows:
nuimotion.Joints.LEFT_HAND = "left_hand";
nuimotion.Joints.RIGHT_HAND = "right_hand";
nuimotion.Joints.LEFT_ELBOW = "left_elbow";
nuimotion.Joints.RIGHT_ELBOW = "right_elbow";
nuimotion.Joints.LEFT_SHOULDER = "left_shoulder";
nuimotion.Joints.RIGHT_SHOULDER = "right_shoulder";
nuimotion.Joints.LEFT_HIP = "left_hip";
nuimotion.Joints.RIGHT_HIP = "right_hip";
nuimotion.Joints.TORSO = "torso";
nuimotion.Joints.HEAD = "head";
Your callback method is returned with one parameter: the skeleton object. The object contains key/value pairs where the key is the joint name, and the value is an object containing:
- x (x coordinate)
- y (y coordinate)
- z (z coordinate)
- xRotation (in degrees)
- yRotation (in degrees)
- zRotation (in degrees)
- isActive (if the joint is in view, and the accuracy level is within tolerance)
- percentExtended (if left or right hand, the percentage that the arm is fully extended out - 100 is a completely straight arm, while around 20 is where the hand is touching the shoulder)
- positionConfidence (how confident we are in the position from 0 to 1)
To access each joint in our callback object, simply access:
skeleton[nuimotion.Joints.LEFT_HAND]