int UpdateUser(int userId, OpenNISkeleton skeleton) { // valid users? if (0 != userId) { // is the user still valid? if (!UserTracker.CalibratedUsers.Contains(userId)) { userId = 0; Skeleton1.RotateToCalibrationPose(); } } // look for a new userId if we dont have one if (0 == userId) { foreach (int uId in UserTracker.CalibratedUsers) { if (!UserIdTaken(uId)) { userId = uId; break; } } } // update our skeleton based on active user id if (0 != userId) { UserTracker.UpdateSkeleton(userId, skeleton); } return userId; }
void UpdateSkeletonJointPosition() { if (SkeletonController.STATIC_SKELETON != null) { OpenNISkeleton tempSkeleton = SkeletonController.STATIC_SKELETON; Head = getXYPosition(tempSkeleton.GetJointRealWorldPosition(SkeletonJoint.Head)); Neck = getXYPosition(tempSkeleton.GetJointRealWorldPosition(SkeletonJoint.Neck)); Torso = getXYPosition(tempSkeleton.GetJointRealWorldPosition(SkeletonJoint.Torso)); Waist = getXYPosition(tempSkeleton.GetJointRealWorldPosition(SkeletonJoint.Waist)); LeftShoulder = getXYPosition(tempSkeleton.GetJointRealWorldPosition(SkeletonJoint.LeftShoulder)); LeftElbow = getXYPosition(tempSkeleton.GetJointRealWorldPosition(SkeletonJoint.LeftElbow)); LeftWrist = getXYPosition(tempSkeleton.GetJointRealWorldPosition(SkeletonJoint.LeftWrist)); LeftHand = getXYPosition(tempSkeleton.GetJointRealWorldPosition(SkeletonJoint.LeftHand)); RightShoulder = getXYPosition(tempSkeleton.GetJointRealWorldPosition(SkeletonJoint.RightShoulder)); RightElbow = getXYPosition(tempSkeleton.GetJointRealWorldPosition(SkeletonJoint.RightElbow)); RightWrist = getXYPosition(tempSkeleton.GetJointRealWorldPosition(SkeletonJoint.RightWrist)); RightHand = getXYPosition(tempSkeleton.GetJointRealWorldPosition(SkeletonJoint.RightHand)); LeftHip = getXYPosition(tempSkeleton.GetJointRealWorldPosition(SkeletonJoint.LeftHip)); LeftKnee = getXYPosition(tempSkeleton.GetJointRealWorldPosition(SkeletonJoint.LeftKnee)); LeftAnkle = getXYPosition(tempSkeleton.GetJointRealWorldPosition(SkeletonJoint.LeftAnkle)); RightHip = getXYPosition(tempSkeleton.GetJointRealWorldPosition(SkeletonJoint.RightHip)); RightKnee = getXYPosition(tempSkeleton.GetJointRealWorldPosition(SkeletonJoint.RightKnee)); RightAnkle = getXYPosition(tempSkeleton.GetJointRealWorldPosition(SkeletonJoint.RightAnkle)); } }
public void UpdateSkeleton(int userId, OpenNISkeleton skeleton) { // make sure we have skeleton data for this user if (!skeletonCapbility.IsTracking(userId)) { return; } // Use torso as root SkeletonJointTransformation skelTrans = new SkeletonJointTransformation(); skelTrans = skeletonCapbility.GetSkeletonJoint(userId, SkeletonJoint.Torso); if (skeleton.absolute) { Point3D pos = skelTrans.Position.Position; skeleton.UpdateRoot(new Vector3(pos.X,pos.Y,pos.Z)); } else { Point3D pos = skelTrans.Position.Position; Vector3 v3dpos = new Vector3(pos.X, pos.Y, -pos.Z); Vector3 calPos = userCalibrationPosition[userId]; skeleton.UpdateRoot(calPos - v3dpos); } // update each joint with data from OpenNI foreach (SkeletonJoint joint in Enum.GetValues(typeof(SkeletonJoint))) { if (skeletonCapbility.IsJointAvailable(joint)) { skelTrans = skeletonCapbility.GetSkeletonJoint(userId, joint); skeleton.UpdateJoint(joint, skelTrans); } } }
void InitialiseUserTracker() { if (!UserTracker) { UserTracker = GetComponent <OpenNIUserTracker>(); } if (!UserTracker) { UserTracker = GameObject.FindObjectOfType(typeof(OpenNIUserTracker)) as OpenNIUserTracker; } if (!UserTracker) { Debug.LogWarning("Missing a User Tracker. Adding..."); UserTracker = gameObject.AddComponent <OpenNIUserTracker>(); } if (UserTracker.MaxCalibratedUsers < 1) { UserTracker.MaxCalibratedUsers = 1; } STATIC_SKELETON = null; }
int UpdateUser(int userId, OpenNISkeleton skeleton) { // valid users? if (0 != userId) { // is the user still valid? if (!UserTracker.CalibratedUsers.Contains(userId)) { userId = 0; Skeleton1.RotateToCalibrationPose(); } } // look for a new userId if we dont have one if (0 == userId) { foreach (int uId in UserTracker.CalibratedUsers) { if (!UserIdTaken(uId)) { userId = uId; break; } } } // update our skeleton based on active user id if (0 != userId) { UserTracker.UpdateSkeleton(userId, skeleton); } return(userId); }
public void UpdateSkeleton(int userId, OpenNISkeleton skeleton) { // make sure we have skeleton data for this user if (!skeletonCapbility.IsTracking(userId)) { return; } // Use torso as root SkeletonJointTransformation skelTrans = new SkeletonJointTransformation(); skelTrans = skeletonCapbility.GetSkeletonJoint(userId, SkeletonJoint.Torso); if (skeleton.absolute) { Point3D pos = skelTrans.Position.Position; skeleton.UpdateRoot(new Vector3(pos.X, pos.Y, pos.Z)); } else { Point3D pos = skelTrans.Position.Position; Vector3 v3dpos = new Vector3(pos.X, pos.Y, -pos.Z); Vector3 calPos = userCalibrationPosition[userId]; skeleton.UpdateRoot(calPos - v3dpos); } // update each joint with data from OpenNI foreach (SkeletonJoint joint in Enum.GetValues(typeof(SkeletonJoint))) { if (skeletonCapbility.IsJointAvailable(joint)) { skelTrans = skeletonCapbility.GetSkeletonJoint(userId, joint); skeleton.UpdateJoint(joint, skelTrans); } } }
void CalibrateUser() { // do we have a valid calibrated user? if (IsTracking) { // is the user still valid? if (!UserTracker.CalibratedUsers.Contains(USER_ID)) { USER_ID = 0; foreach (OpenNISkeleton skel in Skeletons) { skel.RotateToCalibrationPose(); } } } // look for a new userId if we dont have one if (!IsTracking) { // just take the first calibrated user if (UserTracker.CalibratedUsers.Count > 0) { USER_ID = UserTracker.CalibratedUsers[0]; outOfFrame = false; } } // we have a valid userId, lets use it for something! if (IsTracking) { // see if user is out o'frame Vector3 com = UserTracker.GetUserCenterOfMass(USER_ID); if (outOfFrame != (com == Vector3.zero)) { outOfFrame = (com == Vector3.zero); SendMessage("UserOutOfFrame", outOfFrame, SendMessageOptions.DontRequireReceiver); } // update our skeleton based on active user id foreach (OpenNISkeleton skel in Skeletons) { UserTracker.UpdateSkeleton(USER_ID, skel); } // Always update skeleton points STATIC_SKELETON = Skeletons[0]; if (IS_FIRST_RUN) // Only calibrate once { TIME = Time.time; IS_FIRST_RUN = false; } } }
void CalibrateUser() { // do we have a valid calibrated user? if (IsTracking){ // is the user still valid? if (!UserTracker.CalibratedUsers.Contains(USER_ID)){ USER_ID = 0; foreach (OpenNISkeleton skel in Skeletons){ skel.RotateToCalibrationPose(); } } } // look for a new userId if we dont have one if (!IsTracking){ // just take the first calibrated user if (UserTracker.CalibratedUsers.Count > 0){ USER_ID = UserTracker.CalibratedUsers[0]; outOfFrame = false; } } // we have a valid userId, lets use it for something! if (IsTracking){ // see if user is out o'frame Vector3 com = UserTracker.GetUserCenterOfMass(USER_ID); if (outOfFrame != (com == Vector3.zero)){ outOfFrame = (com == Vector3.zero); SendMessage("UserOutOfFrame", outOfFrame, SendMessageOptions.DontRequireReceiver); } // update our skeleton based on active user id foreach (OpenNISkeleton skel in Skeletons){ UserTracker.UpdateSkeleton(USER_ID, skel); } // Always update skeleton points STATIC_SKELETON = Skeletons[0]; if(IS_FIRST_RUN){ // Only calibrate once TIME = Time.time; IS_FIRST_RUN = false; } } }
public void UpdateSkeleton(int userId, OpenNISkeleton skeleton) { // make sure we have skeleton data for this user if (!skeletonCapbility.IsTracking(userId)) { return; } // Use torso as root SkeletonJointTransformation skelTrans = new SkeletonJointTransformation(); skelTrans = skeletonCapbility.GetSkeletonJoint(userId, SkeletonJoint.Torso); skeleton.UpdateRoot(skelTrans.Position.Position); // update each joint with data from OpenNI foreach (SkeletonJoint joint in Enum.GetValues(typeof(SkeletonJoint))) { if (skeletonCapbility.IsJointAvailable(joint)) { skelTrans = skeletonCapbility.GetSkeletonJoint(userId, joint); skeleton.UpdateJoint(joint, skelTrans); } } }
void InitialiseUserTracker() { if (!UserTracker) { UserTracker = GetComponent<OpenNIUserTracker>(); } if (!UserTracker) { UserTracker = GameObject.FindObjectOfType(typeof(OpenNIUserTracker)) as OpenNIUserTracker; } if (!UserTracker) { Debug.LogWarning("Missing a User Tracker. Adding..."); UserTracker = gameObject.AddComponent<OpenNIUserTracker>(); } if (UserTracker.MaxCalibratedUsers < 1) { UserTracker.MaxCalibratedUsers = 1; } STATIC_SKELETON = null; }