private void ProcessFrame(ColorImageFrame colorFrame, DepthImageFrame depthFrame, ReplaySkeletonFrame skeletonFrame) { Dictionary <int, string> stabilities = new Dictionary <int, string>(); foreach (var skeleton in skeletonFrame.Skeletons) { if (skeleton.TrackingState != SkeletonTrackingState.Tracked) { continue; } contextTracker.Add(skeleton.Position.ToVector3(), skeleton.TrackingId); stabilities.Add(skeleton.TrackingId, contextTracker.IsStableRelativeToCurrentSpeed(skeleton.TrackingId) ? "Stable" : "Non stable"); if (!contextTracker.IsStableRelativeToCurrentSpeed(skeleton.TrackingId)) { continue; } SkeletonPoint center = skeleton.Position; foreach (Joint joint in skeleton.Joints) { if (joint.JointType == JointType.HandLeft) { if (center.Z - joint.Position.Z > 0.25) { OnGestureDetected(GestureType.LeftInFront.ToString(), center.Z - joint.Position.Z); } } else if (joint.JointType == JointType.HandRight) { if (center.Z - joint.Position.Z > 0.25) { OnGestureDetected(GestureType.RightInFront.ToString(), center.Z - joint.Position.Z); } } } if (EnsureHeadTracker()) { byte[] colorImage = new byte[colorFrame.PixelDataLength]; colorFrame.CopyPixelDataTo(colorImage); short[] depthImage = new short[depthFrame.PixelDataLength]; depthFrame.CopyPixelDataTo(depthImage); var result = HeadTracker.Track(colorFrame.Format, colorImage, depthFrame.Format, depthImage, skeleton); if (result.TrackSuccessful) { if (FaceTracked != null) { FaceTracked(this, new FaceTrackedEventArgs() { Pitch = result.Rotation.X, Roll = result.Rotation.Z, Yaw = result.Rotation.Y }); } } } } }
void UpdateSkeletonDisplay(ReplaySkeletonFrame frame) { if (frame.Skeletons == null) { return; } Dictionary <int, string> stabilities = new Dictionary <int, string>(); foreach (var skeleton in frame.Skeletons) { if (skeleton.TrackingState != SkeletonTrackingState.Tracked) { continue; } contextTracker.Add(skeleton.Position.ToVector3(), skeleton.TrackingId); stabilities.Add(skeleton.TrackingId, contextTracker.IsStableRelativeToCurrentSpeed(skeleton.TrackingId) ? "Stable" : "Non stable"); } try { if (viewSkeleton && skeletonDisplayManager != null) { skeletonDisplayManager.Draw(frame.Skeletons, false, HandInputParams.ColorImageFormat); } else { skeletonCanvas.Children.Clear(); } } catch (Exception e) { Log.Error(e.Message); } }
void ProcessFrame(ReplaySkeletonFrame frame) { Dictionary <int, string> stabilities = new Dictionary <int, string>(); foreach (var skeleton in frame.Skeletons) { if (skeleton.TrackingState != SkeletonTrackingState.Tracked) { continue; } contextTracker.Add(skeleton.Position.ToVector3(), skeleton.TrackingId); stabilities.Add(skeleton.TrackingId, contextTracker.IsStableRelativeToCurrentSpeed(skeleton.TrackingId) ? "Stable" : "Non stable"); if (!contextTracker.IsStableRelativeToCurrentSpeed(skeleton.TrackingId)) { continue; } foreach (Joint joint in skeleton.Joints) //오른손기능구현부 { if (joint.TrackingState != JointTrackingState.Tracked) { continue; } if (joint.JointType == JointType.HandRight) { circleGestureRecognizer.Add(joint.Position, kinectSensor); triangleGestureRecognizer.Add(joint.Position, kinectSensor); //Add Triangle switch (swipeGestureRecognizer.icon_bit) { case 0: if (swipeGestureRecognizer.cir_bit == 0x01) //브라우져 영역 { controlMouse.IsChecked = true; Browser_grid.Visibility = Visibility.Visible; } break; case 1: if (swipeGestureRecognizer.cir_bit == 0x01) //빙맵 영역 { BingMap_Loaded(); } break; case 2: if (swipeGestureRecognizer.cir_bit == 0x01) { gdDoc.Visibility = Visibility.Visible; btnDocument_Click(); PPT_Loaded(); //추가 } break; case 3: if (swipeGestureRecognizer.cir_bit == 0x01) //미디어 영역 { Media_Loaded(); } break; case 4: if (swipeGestureRecognizer.cir_bit == 0x01) { gdPicture.Visibility = Visibility.Visible; if (swipeGestureRecognizer.cir_bit == 0x03) { //처음 서클비트가 1이들어가 그냥출력하게 해봄 swipeGestureRecognizer.pic_bit = 0; gdPicture.Visibility = Visibility.Hidden; gdPicture.Visibility = Visibility.Visible; btnPicture_Click(); } else { btnPicture_Click(); } } break; case 5: if (swipeGestureRecognizer.cir_bit == 0x01) { gdVideo.Visibility = Visibility.Visible; btnVideo_Click(); } break; default: break; } } else if (joint.JointType == JointType.HandLeft) //왼손 구현부 { swipeGestureRecognizer.Add(joint.Position, kinectSensor); if (controlMouse.IsChecked == true) { MouseController.Current.SetHandPosition(kinectSensor, joint, skeleton); } //sw1 = pic_bit; switch (swipeGestureRecognizer.sw_bit) //프로세스 영역 죽이는 구현부 { case 0x01: controlMouse.IsChecked = false; Browser_grid.Visibility = Visibility.Hidden; //인터넷창 없앰 foreach (Process p in Process.GetProcessesByName("iexplore")) { p.Kill(); } foreach (Process p in Process.GetProcessesByName("wmplayer")) //추가 { p.Kill(); } swipeGestureRecognizer.cir_bit = 0x00; // Swipe Up 에 의한 Cir_bit의 초기화 break; //Internet Swipe_Up => Run.... 닫기 동작에 대한 정의 case 0x02: swipeGestureRecognizer.cir_bit = 0x00; break; //Bing Map => Run.... case 0x04: gdDoc.Visibility = Visibility.Hidden; foreach (Process p in Process.GetProcessesByName("POWERPNT")) { p.Kill(); } swipeGestureRecognizer.cir_bit = 0x00; break; case 0x08: // Media Ended foreach (Process p in Process.GetProcessesByName("wmplayer")) //추가 { p.Kill(); } swipeGestureRecognizer.cir_bit = 0x00; break; case 0x10: gdPicture.Visibility = Visibility.Hidden; swipeGestureRecognizer.cir_bit = 0x00; break; case 0x20: foreach (Process p in Process.GetProcessesByName("wmplayer")) //추가 { p.Kill(); } gdVideo.Visibility = Visibility.Hidden; swipeGestureRecognizer.cir_bit = 0x00; break; } } } algorithmicPostureRecognizer.TrackPostures(skeleton); templatePostureDetector.TrackPostures(skeleton); if (recordNextFrameForPosture) { templatePostureDetector.AddTemplate(skeleton); recordNextFrameForPosture = false; } } //skeletonDisplayManager.Draw(frame.Skeletons, seatedMode.IsChecked == true); stabilitiesList.ItemsSource = stabilities; }
private void ProcessGestures() { Dictionary <int, string> stabilities = new Dictionary <int, string>(); Skeleton activeSkeleton = this.skeletons.FirstOrDefault(skeleton => skeleton.TrackingId == this.PrimaryUserTrackingId); if (activeSkeleton == null) { return; } contextTracker.Add(activeSkeleton.Position.ToVector3(), activeSkeleton.TrackingId); if (!contextTracker.IsStableRelativeToCurrentSpeed(activeSkeleton.TrackingId)) { return; } //Joint leftHandJoint= activeSkeleton.Joints[JointType.HandLeft]; //leftHandSwipeGestureRecogniser.Add(leftHandJoint.Position, this.KinectSensor); Joint rightHandJoint = activeSkeleton.Joints[JointType.HandRight]; rightHandSwipeGestureRecogniser.Add(rightHandJoint.Position, this.KinectSensor); //foreach (var skeleton in frame.Skeletons) //{ // if (skeleton.TrackingState != SkeletonTrackingState.Tracked) // continue; // //if (eyeTracker == null) // // eyeTracker = new EyeTracker(kinectSensor); // //eyeTracker.Track(skeleton); // contextTracker.Add(skeleton.Position.ToVector3(), skeleton.TrackingId); // stabilities.Add(skeleton.TrackingId, contextTracker.IsStableRelativeToCurrentSpeed(skeleton.TrackingId) ? "Stable" : "Non stable"); // if (!contextTracker.IsStableRelativeToCurrentSpeed(skeleton.TrackingId)) // continue; // //if (eyeTracker.IsLookingToSensor.HasValue && eyeTracker.IsLookingToSensor == false) // // continue; // foreach (Joint joint in skeleton.Joints) // { // if (joint.TrackingState != JointTrackingState.Tracked) // continue; // if (joint.JointType == JointType.HandRight) // { // circleGestureRecognizer.Add(joint.Position, kinectSensor); // } // else if (joint.JointType == JointType.HandLeft) // { // swipeGestureRecognizer.Add(joint.Position, kinectSensor); // if (controlMouse.IsChecked == true) // MouseController.Current.SetHandPosition(kinectSensor, joint, skeleton); // } // } // algorithmicPostureRecognizer.TrackPostures(skeleton); // templatePostureDetector.TrackPostures(skeleton); // if (recordNextFrameForPosture) // { // templatePostureDetector.AddTemplate(skeleton); // recordNextFrameForPosture = false; // } //} //skeletonDisplayManager.Draw(frame.Skeletons, seatedMode.IsChecked == true); //stabilitiesList.ItemsSource = stabilities; }
void ProcessFrame(ReplaySkeletonFrame frame) { Dictionary <int, string> stabilities = new Dictionary <int, string>(); foreach (var skeleton in frame.Skeletons) { if (skeleton.TrackingState != SkeletonTrackingState.Tracked) { continue; } //if (eyeTracker == null) // eyeTracker = new EyeTracker(kinectSensor); //eyeTracker.Track(skeleton); contextTracker.Add(skeleton.Position.ToVector3(), skeleton.TrackingId); stabilities.Add(skeleton.TrackingId, contextTracker.IsStableRelativeToCurrentSpeed(skeleton.TrackingId) ? "Stable" : "Non stable"); if (!contextTracker.IsStableRelativeToCurrentSpeed(skeleton.TrackingId)) { continue; } //if (eyeTracker.IsLookingToSensor.HasValue && eyeTracker.IsLookingToSensor == false) // continue; foreach (Joint joint in skeleton.Joints) { if (joint.TrackingState != JointTrackingState.Tracked) { continue; } if (joint.JointType == JointType.HandRight) { circleGestureRecognizer.Add(joint.Position, kinectSensor); } else if (joint.JointType == JointType.HandLeft) { swipeGestureRecognizer.Add(joint.Position, kinectSensor); if (controlMouse.IsChecked == true) { MouseController.Current.SetHandPosition(kinectSensor, joint, skeleton); } } } algorithmicPostureRecognizer.TrackPostures(skeleton); templatePostureDetector.TrackPostures(skeleton); if (recordNextFrameForPosture) { templatePostureDetector.AddTemplate(skeleton); recordNextFrameForPosture = false; } } skeletonDisplayManager.Draw(frame.Skeletons, seatedMode.IsChecked == true); stabilitiesList.ItemsSource = stabilities; }