/* * Kinect 1 */ public Vector3 ConvertRawKinectLocation(OpenNI.Point3D position) { //we have to flip the z axis to get into unity's coordinate system Vector3 newPosition = Vector3.zero; newPosition.x = position.X; newPosition.y = position.Y; newPosition.z = -position.Z; newPosition = kinectToUnityScale * newPosition; return(newPosition); }
/// <summary> /// this routine checks if the hand is open or not. Openness of the palm is currently indicated /// by at least 3 visible fingers sticking out of the profile of the hand. /// </summary> /// <param name="clipping"></param> /// <param name="handPoint"></param> /// <returns></returns> public int isDetected(byte[,] clipping, OpenNI.Point3D handPoint) { /*Since this class is a child of the HandFeature class, we can directly invoke the hand feature extraction routines from * the parent class. The result of the parent class is stored in its data structures viz. fingerTips. This list of points is * accessible using a getter. * * if the number of fingers clearly detected is greater that 3, indicate that the palm has been opened */ HandFeature featuer = new HandFeature(); int status = featuer.isDetected(ref clipping, handPoint); return(status); }
public Vector3 ConvertKinectPosition(OpenNI.Point3D position) { //we have to flip the z axis to get into unity's coordinate system Vector3 newPosition = Vector3.zero; newPosition.x = position.X; newPosition.y = position.Y; newPosition.z = -position.Z; newPosition = kinectToUnityScale * (Quaternion.Euler(0, yawOffset, 0) * kinectFloorRotator * newPosition); if (setKinectOriginToFloor) { newPosition.y += kinectDistanceFromFloor; } newPosition += positionOffset; return(newPosition); }
void DrawLineBetweenJoints(OpenNI.SkeletonJoint first, OpenNI.SkeletonJoint second) { NISelectedPlayer player = playerSelection.GetPlayer(0); OpenNI.SkeletonJointPosition firstJointPosition; player.GetSkeletonJointPosition(first, out firstJointPosition); OpenNI.SkeletonJointPosition secondJointPosition; player.GetSkeletonJointPosition(second, out secondJointPosition); if (firstJointPosition.Confidence <= 0.5 || secondJointPosition.Confidence <= 0.5) { return; } OpenNI.Point3D firstJointScreenPosition = depthGenerator.ConvertRealWorldToProjective(firstJointPosition.Position); OpenNI.Point3D secondJointScreenPosition = depthGenerator.ConvertRealWorldToProjective(secondJointPosition.Position); DrawLine.DrawSimpleLine(ref mapPixels, (int)(width - firstJointScreenPosition.X / factor), (int)(height - firstJointScreenPosition.Y / factor), (int)(width - secondJointScreenPosition.X / factor), (int)(height - secondJointScreenPosition.Y / factor), width, height, Color.white); }