// Initialize OpenNI context and create user generator object. openni::Status status = openni::STATUS_OK; openni::Device device; status = openni::OpenNI::initialize(); status = device.open(openni::ANY_DEVICE); openni::UserGenerator userGenerator; status = userGenerator.create(device); // Enable skeleton tracking and set up a callback function. userGenerator.GetSkeletonCap().SetSkeletonProfile(XN_SKEL_PROFILE_ALL); userGenerator.RegisterUserCallbacks(UserHandler, NULL); // Get joint positions data of all tracked users. XnUserID aUsers[10]; XnUInt16 nUsers = 10; userGenerator.GetUsers(aUsers, nUsers); for (int i = 0; i < nUsers; ++i) { if (userGenerator.GetSkeletonCap().IsTracking(aUsers[i])) { XnSkeletonJointPosition jointPosition; userGenerator.GetSkeletonCap().GetSkeletonJointPosition(aUsers[i], XN_SKEL_HEAD, jointPosition); cout << "User " << aUsers[i] << ": Head position: (" << jointPosition.position.X << ", " << jointPosition.position.Y << ", " << jointPosition.position.Z << ")" << endl; } }This example shows how to enable skeleton tracking and set up a callback function to handle user events. It also demonstrates how to get the joint positions data of all tracked users, specifically the head position of each user. This code example uses the OpenNI2 C++ library.