/// <summary> /// Decrease Kinect elevation. It will have the value of the previous elevation in the list. /// If the min value is already reached, it does nothing. /// </summary> public void downElevation() { if (SelectedElevation > 1) { GeneralSideTool.Get().ManualElevationCB.SelectedIndex = SelectedElevation - 1; } }
///<summary> ///Releasing the media elements when closing the replay window ///Switch to recording mode ///Written by Baptiste Germond ///</summary> private void quit() { isReplaying = false; statisticsPath = ""; if (skeletonScrolling != null) { skeletonScrolling.Stop(); skeletonScrolling = null; } (TrainingSideTool.Get().FindResource("StopReplayButtonAction") as Storyboard).Begin(); DrawingSheetView.Get().ReplayVideo.Close(); DrawingSheetView.Get().ReplayVideo.Source = null; DrawingSheetView.Get().ReplayAudio.Close(); DrawingSheetView.Get().ReplayAudio.Source = null; ReplayView.Get().SoundCheckbox.IsChecked = false; SideToolsViewModel.Get().enableTrackingAndTrainingTab(); TrainingSideToolViewModel.Get().recordingMode(); DrawingSheetAvatarViewModel.Get().normalMode(); // reactivate the sensors KinectDevice.sensor.SkeletonStream.Enable(); if (faceTrack) { KinectDevice.faceTracking = true; } TrackingSideToolViewModel.get().SpeedRate = speedRateActive; // reactivate the audience if (TrainingSideToolViewModel.audienceOn) { TrainingSideToolViewModel.audienceOn = false; GeneralSideTool.Get().AudienceControlCheckBox.IsChecked = true; } }
/// <summary> /// Increase Kinect elevation. It will have the value of the next elevation in the list. /// If the max value is already reached, it does nothing. /// </summary> public void upElevation() { if (SelectedElevation < elevationList.Count - 1) { GeneralSideTool.Get().ManualElevationCB.SelectedIndex = SelectedElevation + 1; } }
/// <summary> /// Manage the loading of the file the user choose /// Added by Baptiste Germond /// </summary> private void ManagePerformanceFiles() { if (File.Exists(filePath)) { if (Path.GetFileName(filePath) == "stream.avi") { folderPath = filePath.Remove(filePath.Length - 10); DrawingSheetView.Get().ShowReplayVideoSheet(); filePathVideoStream = filePath; activate(ReplayView.Get().Stream, GeneralSideTool.Get().Stream); DrawingSheetView.Get().ReplayVideo.Source = new Uri(filePathVideoStream, UriKind.Relative); skeletonScrolling = null; DrawingSheetView.Get().CanvasFeedback.Visibility = Visibility.Visible; tryAddOtherSources("stream.avi"); isReplaying = true; } else if (Path.GetFileName(filePath) == "avatarSkeletonData.skd") { try { folderPath = filePath.Remove(filePath.Length - 22); skdRead = true; DrawingSheetView.Get().Show3DSheet(); filePathAvatar = filePath; activate(ReplayView.Get().Avatar, GeneralSideTool.Get().Avatar); voiceData = filePath.Replace("avatarSkeletonData.skd", "tonePeakData.xml"); if (!File.Exists(voiceData)) { voiceData = ""; } faceData = filePath.Replace("avatarSkeletonData.skd", "faceData.xml"); if (!File.Exists(faceData)) { faceData = ""; } skeletonScrolling = new ReplayAvatar(filePathAvatar, faceData, voiceData, this); tryAddOtherSources("avatarSkeletonData.skd"); isReplaying = true; } catch (XmlLoadingException) { throw; } } if (isReplaying) { ReplayView.Get().TitleReplay.Content = Path.GetFileName((Path.GetDirectoryName(filePath))); } } }
public void setGeneralV(GeneralSideTool gst) { this.generalV = gst; }
/// <summary> /// Voice control main function. Links every key to an action. /// </summary> /// <param name="value"></param> public void speechRecognized(string value) { if (generalV.VoiceControlCheckBox.IsChecked == true) { Storyboard sb = null; switch (value) { case "QUIT": Application.Current.Shutdown(); break; case "STREAM": this.generalV.Stream.IsChecked = true; activeStream(); break; case "AUTOELEVATION": this.generalV.AutoElevation.IsChecked = true; activeAutoElevation(); break; case "MANUAL": this.generalV.AutoElevation.IsChecked = false; disableAutoElevation(); break; case "GENERAL": sb = this.sideToolV.FindResource("generalTabSelected") as Storyboard; sb.Begin(); sb = this.sideToolV.FindResource("GeneralTabVisible") as Storyboard; sb.Begin(); break; case "BODY": case "FACE": case "SOUND": case "TRACKING": sb = this.sideToolV.FindResource("TrackingTabSelected") as Storyboard; sb.Begin(); sb = this.sideToolV.FindResource("TrackingTabVisible") as Storyboard; sb.Begin(); break; case "TRAINING": sb = this.sideToolV.FindResource("TrainingSelected") as Storyboard; sb.Begin(); sb = this.sideToolV.FindResource("TrainingTabVisible") as Storyboard; sb.Begin(); break; case "RECORD": if (this.trainingVM.State == IRecordingState.Paused || this.trainingVM.State == IRecordingState.RequestedStop || this.trainingVM.State == IRecordingState.Stopped) { Button b = this.trainingV.FindName("startRecordingButton") as Button; b.RaiseEvent(new RoutedEventArgs(Button.ClickEvent)); b.Command.Execute(null); } else if (this.trainingVM.State == IRecordingState.Monitoring || this.trainingVM.State == IRecordingState.Recording) { Button b = this.trainingV.FindName("stopRecordingButton") as Button; b.RaiseEvent(new RoutedEventArgs(Button.ClickEvent)); b.Command.Execute(null); } break; case "UP": (GeneralSideTool.Get().DataContext as GeneralSideToolViewModel).upElevation(); break; case "DOWN": (GeneralSideTool.Get().DataContext as GeneralSideToolViewModel).downElevation(); break; } } }
/// <summary> /// Main method to recognize which view area the user is looking at /// Modified by Baptiste Germond /// </summary> public static void lookRecognizer() { //Using a counter so it won't go to much in the try/catch and make the software lag //It prevents the method to be executed if the face is not recognize if (count == 30 || faceDetected == true) { count = 0; int direction = 0; try { var temp = KinectDevice.skeletonFaceTracker.facePoints3D; try { faceDetected = true; var rightEye = temp.ElementAt(20); var leftEye = temp.ElementAt(53); //Test if the user is looking at the center area if (rightEye.Z - leftEye.Z >= -0.015 && rightEye.Z - leftEye.Z <= 0.015) { // add look center if (rec) { if (!lookCenter.Contains((int)(Tools.getStopWatch() / 100))) { lookCenter.Add((int)(Tools.getStopWatch() / 100)); } } /*If he just entered the zone (!centre) * and he is not just passing by to go to another area (countC > 4)*/ if (!centre && countC > 4) { addHistorical(CENTER); //Adding the center area to the historical boolManagement(CENTER); // Indicate that the user is looking at the center and reseting all counter } countC++; //Counter to know howlong the user is looking at the same view area direction = CENTER; } //Test if the user is looking at the right area else if (rightEye.Z - leftEye.Z >= -0.057 && rightEye.Z - leftEye.Z < -0.015) { // add look rigth if (rec) { if (!lookRight.Contains((int)(Tools.getStopWatch() / 100))) { lookRight.Add((int)(Tools.getStopWatch() / 100)); } } if (!right) { addHistorical(RIGHT); boolManagement(RIGHT); } countR++; direction = RIGHT; } //Test if the user is looking at the extrem right area else if (rightEye.Z - leftEye.Z < -0.057) { // add look ExtrRight if (rec) { if (!lookExtrRight.Contains((int)(Tools.getStopWatch() / 100))) { lookExtrRight.Add((int)(Tools.getStopWatch() / 100)); } } if (!extremRight) { addHistorical(RIGHT); boolManagement(EXTRIGHT); } countER++; direction = EXTRIGHT; } //Test if the user is looking at the left area else if (rightEye.Z - leftEye.Z > 0.015 && rightEye.Z - leftEye.Z <= 0.057) { // add look left if (rec) { if (!lookLeft.Contains((int)(Tools.getStopWatch() / 100))) { lookLeft.Add((int)(Tools.getStopWatch() / 100)); } } if (!left) { addHistorical(LEFT); boolManagement(LEFT); } countL++; direction = LEFT; } else if (rightEye.Z - leftEye.Z > 0.057) { // add look ExtrLeft if (rec) { if (!lookExtrLeft.Contains((int)(Tools.getStopWatch() / 100))) { lookExtrLeft.Add((int)(Tools.getStopWatch() / 100)); } } if (!extremLeft) { addHistorical(LEFT); boolManagement(EXTLEFT); } countEL++; direction = EXTLEFT; } if (GeneralSideTool.Get().AudienceControlCheckBox.IsChecked == true) { AudienceMember.updateAudienceInterest(direction); } //If the user is still looking at the same view area and if the counter reached the limit if (centre && countC > limitHigh) { int lessUsed = countInHistorical(RIGHT, LEFT); //We decide which was less used between the two other areas updateFeedback(lessUsed); //We display the feedback to notifie the user that he should look at another area feedbackActive = true; } else if (right && countR > limitHigh) { int lessUsed = countInHistorical(CENTER, LEFT); updateFeedback(lessUsed); feedbackActive = true; } else if (extremRight && countER > limitLow) { int lessUsed = countInHistorical(CENTER, LEFT); updateFeedback(lessUsed); feedbackActive = true; } else if (left && countL > limitHigh) { int lessUsed = countInHistorical(CENTER, RIGHT); updateFeedback(lessUsed); feedbackActive = true; } else if (extremLeft && countEL > limitLow) { int lessUsed = countInHistorical(CENTER, RIGHT); updateFeedback(lessUsed); feedbackActive = true; } else { //Value very different from the others which means that all feedback should be deactivate updateFeedback(-100); feedbackActive = false; } if (rec) { if (feedbackActive) { lookingDirectionRecord.Add(Tools.getStopWatch() / 1000.0, 1); } else { lookingDirectionRecord.Add(Tools.getStopWatch() / 1000.0, 0); } } } catch (System.ArgumentException) { faceDetected = false; } } catch (NullReferenceException) { faceDetected = false; } } else { count++; } }