public bool getLastRecord(out Skeleton paramSkeleton , out AppropriateJointInfo paramAptJoint) { paramSkeleton = skeletons.ElementAt(skeletons.Count - 1); paramAptJoint = aptJoints.ElementAt(skeletons.Count - 1); return true; }
public int addToDatabase(Skeleton skeleton , AppropriateJointInfo aptJoint) { skeletons.Add(skeleton); aptJoints.Add(aptJoint); return skeletons.Count; }
public bool getRecord(int index , out Skeleton paramSkeleton, out AppropriateJointInfo paramAptJoint) { paramAptJoint = new AppropriateJointInfo(); paramSkeleton = new Skeleton(); if (index < 0 || index > skeletons.Count) { System.Windows.Forms.MessageBox.Show("Message: Error! Invalid Index "+ index +"| Method : getRecord | Class: GestureDatabase"); return false; } paramSkeleton = skeletons.ElementAt(index); paramAptJoint = aptJoints.ElementAt(index); return true; }
public void copyDataTo(SkeletonFrame frame) { // process the frames here , get all the tracked Joints and add them to Database. // dont copy first 60 frames used to stabilize skeletons and filter out garbage data if (++this.framesSkipped <= INITIAL_NUM_OF_FRAMES_TO_SKIP) { return; } frame.CopySkeletonDataTo(tempSkeletonFrames); for (int i = 0; i < 6; i++) { tempSkeleton = tempSkeletonFrames[i]; if (tempSkeleton.TrackingState == SkeletonTrackingState.Tracked) { aptJoint = trackAptJoints(tempSkeleton); if (aptJoint == null) continue; int count = gestureDatabase.addToDatabase(tempSkeleton, aptJoint); onProcessGestures(); } } }
public void addToGestureDatabase(Skeleton skeleton , AppropriateJointInfo aptJoint) { gestureDatabase.addToDatabase(skeleton, aptJoint); }
private AppropriateJointInfo trackAptJoints(Skeleton skeleton) { AppropriateJointInfo aptJointInfo = new AppropriateJointInfo(); bool isJointNotTracked = false; aptJointInfo.skeletonTrackingID = skeleton.TrackingId; if (skeleton.Joints[JointType.WristLeft].TrackingState == JointTrackingState.Tracked) { aptJointInfo.handLeftPos = skeleton.Joints[JointType.WristLeft].Position; scaleUp(ref aptJointInfo.handLeftPos); } else { isJointNotTracked = true; } if (skeleton.Joints[JointType.ShoulderLeft].TrackingState == JointTrackingState.Tracked) { aptJointInfo.shoulderLeftPos = skeleton.Joints[JointType.ShoulderLeft].Position; scaleUp(ref aptJointInfo.shoulderLeftPos); } else { isJointNotTracked = true; } if (skeleton.Joints[JointType.ElbowLeft].TrackingState == JointTrackingState.Tracked) { aptJointInfo.elbowLeftPos = skeleton.Joints[JointType.ElbowLeft].Position ; scaleUp(ref aptJointInfo.elbowLeftPos); } else { isJointNotTracked = true; } if (skeleton.Joints[JointType.WristRight].TrackingState == JointTrackingState.Tracked) { aptJointInfo.handRightPos = skeleton.Joints[JointType.WristRight].Position; scaleUp(ref aptJointInfo.handRightPos); } else { isJointNotTracked = true; } if (skeleton.Joints[JointType.ShoulderRight].TrackingState == JointTrackingState.Tracked) { aptJointInfo.shoulderRightPos = skeleton.Joints[JointType.ShoulderRight].Position ; scaleUp(ref aptJointInfo.shoulderRightPos); } else { isJointNotTracked = true; } if (skeleton.Joints[JointType.ElbowRight].TrackingState == JointTrackingState.Tracked) { aptJointInfo.elbowRightPos = skeleton.Joints[JointType.ElbowRight].Position ; scaleUp(ref aptJointInfo.elbowRightPos); } else { isJointNotTracked = true; } if (skeleton.Joints[JointType.Head].TrackingState == JointTrackingState.Tracked) { aptJointInfo.headPos = skeleton.Joints[JointType.Head].Position; scaleUp(ref aptJointInfo.headPos); } else { isJointNotTracked = true; } if (skeleton.Joints[JointType.ShoulderCenter].TrackingState == JointTrackingState.Tracked) { aptJointInfo.shoulderCenterPos = skeleton.Joints[JointType.ShoulderCenter].Position; scaleUp(ref aptJointInfo.shoulderCenterPos); } else { isJointNotTracked = true; } if (skeleton.Joints[JointType.Spine].TrackingState == JointTrackingState.Tracked) { aptJointInfo.spinePos = skeleton.Joints[JointType.Spine].Position ; scaleUp(ref aptJointInfo.spinePos); } else { isJointNotTracked = true; } if (skeleton.Joints[JointType.HipCenter].TrackingState == JointTrackingState.Tracked) { aptJointInfo.hipCenterPos = skeleton.Joints[JointType.HipCenter].Position ; scaleUp(ref aptJointInfo.hipCenterPos); } else { isJointNotTracked = true; } using (System.IO.StreamWriter file = new System.IO.StreamWriter("C:/t.txt", true)) { file.WriteLine(aptJointInfo.handRightPos.X + " " + aptJointInfo.handRightPos.Y + " " + aptJointInfo.handRightPos.Z); file.WriteLine(aptJointInfo.spinePos.X + " " + aptJointInfo.spinePos.Y + " " + aptJointInfo.spinePos.Z); file.WriteLine(aptJointInfo.shoulderRightPos.X + " " + aptJointInfo.shoulderRightPos.Y + " " + aptJointInfo.shoulderRightPos.Z); file.WriteLine(); } if (isJointNotTracked) return null; return aptJointInfo; }
public void addToDatabase(AppropriateJointInfo aptJoint) { aptJoints.Add(aptJoint); }