/// <summary> /// Deserialize/read the session file and use the loading of the personalization /// Called when a user open his session /// </summary> public void deserializeSession(string pathString) { using (System.IO.StreamReader projectFile = new System.IO.StreamReader(pathString)) { Main.session.userFirstName = JsonConvert.DeserializeObject <string>(projectFile.ReadLine()); Main.session.userLastName = JsonConvert.DeserializeObject <string>(projectFile.ReadLine()); Main.session.sessionPath = JsonConvert.DeserializeObject <string>(projectFile.ReadLine()); Main.session.themeName = JsonConvert.DeserializeObject <string>(projectFile.ReadLine()); DrawingSheetAvatarViewModel.Get().modifColorOpenGL(Main.session.themeName); while (!projectFile.EndOfStream) { string temp = JsonConvert.DeserializeObject <string>(projectFile.ReadLine()); string[] tabTemp = temp.Split('_'); if (!personalization.ContainsKey(tabTemp[0])) { personalization[tabTemp[0]] = new byte[4]; } personalization[tabTemp[0]][0] = (byte)Int32.Parse(tabTemp[1]); personalization[tabTemp[0]][1] = (byte)Int32.Parse(tabTemp[2]); personalization[tabTemp[0]][2] = (byte)Int32.Parse(tabTemp[3]); personalization[tabTemp[0]][3] = (byte)Int32.Parse(tabTemp[4]); loadPerso(); } } }
///<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; } }
public void StopVideoTraining() { SideToolsViewModel.Get().enableTrackingAndTrainingTab(); (TrainingSideTool.Get().FindResource("StopVideoTraining") as Storyboard).Begin(); VideosNameList = new List <VideosList>(); DrawingSheetAvatarViewModel.Get().isTraining = false; SkeletonList = null; }
private void CheckBoxFF_Checked(object sender, RoutedEventArgs e) { DrawingSheetAvatarViewModel.Get().diplayFaceFeedback = false; if (FeedbackBodyCheckBox.IsChecked.Value) { DrawingSheetAvatarViewModel.Get().diplayFeedback = false; FeedbackCheckBox.IsChecked = true; } }
private void ResetColorRessources() { DrawingSheetAvatarViewModel.Get().modifColorOpenGL("Default"); App.Current.Resources["UnselectedTabColor"] = mainBackgroundColor; App.Current.Resources["SelectedTabColor"] = mainTabColor; App.Current.Resources["GeneralTextColor"] = mainFontColor; App.Current.Resources["FeedbackStreamColor"] = Color.FromArgb(255, 128, 128, 128); IconViewModel.get().setFFT((Color)App.Current.Resources["GeneralTextColor"], (Color)App.Current.Resources["UnselectedTabColor"]); DrawingSheetStreamViewModel.Get().changeColorFeedbacks(); Main.session.fillPersoWithActual(); }
/// <summary> /// Changing the theme displayed in this panel when the selection of the combo box change /// </summary> private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { foreach (ThemeOpenGL t in DrawingSheetAvatarViewModel.Get().getThemeList) { if (t.Name == comboBox.SelectedItem.ToString()) { loadColor(t); break; } } }
private void CheckBoxF_Unchecked(object sender, RoutedEventArgs e) { DrawingSheetAvatarViewModel.Get().diplayFeedback = true; { FeedbackBodyCheckBox.IsChecked = false; DrawingSheetAvatarViewModel.Get().diplayBodyFeedback = true; } { FeedbackFaceCheckBox.IsChecked = false; DrawingSheetAvatarViewModel.Get().diplayFaceFeedback = true; } }
/// <summary> /// if the user press ok /// </summary> private void ChangeFeedbacks() { DrawingSheetAvatarViewModel.Get().displayAgitationFeedback = choiceFeedbackView.AgitationChoiceFeedback.IsChecked.Value; DrawingSheetAvatarViewModel.Get().displayArmsCrossedFeedback = choiceFeedbackView.ArmsCrossedChoiceFeedback.IsChecked.Value; DrawingSheetAvatarViewModel.Get().displayHandsJoinedFeedback = choiceFeedbackView.HandsJoinedChoiceFeedback.IsChecked.Value; if (TrackingSideTool.Get().ActivateFaceTrackingCheckBox.IsChecked.Value) { DrawingSheetAvatarViewModel.Get().displayEmotionFeedback = choiceFeedbackView.EmotionChoiceFeedback.IsChecked.Value; DrawingSheetAvatarViewModel.Get().displayLookDirFeedback = choiceFeedbackView.LookDirecChoiceFeedback.IsChecked.Value; } choiceFeedbackView.Close(); }
public ExportAvatarVideoView() { // initializes the view InitializeComponent(); lengthSkeletonList = ReplayAvatar.SkeletonList.Count - 1; ExportProgressBar.Maximum = lengthSkeletonList; ExportProgressBar.Value = 0; // it opens the videoFileWriter on the current replay folder and get the width and height of the current screen avatarVideoStreamWriter = new VideoFileWriter(); var tuple = DrawingSheetAvatarViewModel.Get().getWidthAndHeight(); avatarVideoStreamWriter.Open(ReplayViewModel.Get().folderPath + "avatar.avi", tuple.Item1, tuple.Item2, 30, VideoCodec.MPEG4, 1000000); }
public DrawingSheetView() { InitializeComponent(); initializeGLControl(); DrawingSheetStreamViewModel.Get(this); DrawingSheetAvatarViewModel.Get(this); sheet = DrawingSheetAvatarViewModel.Get(this); this.DataContext = sheet; MyImage.Source = sheet.getImage(); this.mode = SheetMode.AvatarMode; ChangeMode(SheetMode.StreamMode); ChangeMode(SheetMode.AvatarMode); instance = this; }
/// <summary> /// initialize the view according the current feedbacks selected or not /// </summary> private void InitCheckbox() { AgitationChoiceFeedback.IsChecked = DrawingSheetAvatarViewModel.Get().displayAgitationFeedback; if (DrawingSheetAvatarViewModel.Get().displayHandsJoinedFeedback&& DrawingSheetAvatarViewModel.Get().displayArmsCrossedFeedback) { ArmsChoiceFeedback.IsChecked = true; } HandsJoinedChoiceFeedback.IsChecked = DrawingSheetAvatarViewModel.Get().displayHandsJoinedFeedback; ArmsCrossedChoiceFeedback.IsChecked = DrawingSheetAvatarViewModel.Get().displayArmsCrossedFeedback; if (TrackingSideTool.Get().ActivateFaceTrackingCheckBox.IsChecked.Value) { if (DrawingSheetAvatarViewModel.Get().displayEmotionFeedback&& DrawingSheetAvatarViewModel.Get().displayLookDirFeedback) { FaceChoiceFeedback.IsChecked = true; } EmotionChoiceFeedback.IsChecked = DrawingSheetAvatarViewModel.Get().displayEmotionFeedback; LookDirecChoiceFeedback.IsChecked = DrawingSheetAvatarViewModel.Get().displayLookDirFeedback; } }
public ChoiceTheme() { InitializeComponent(); this.DataContext = this; //Ordering the themes by alphabetical order var temp = from element in DrawingSheetAvatarViewModel.Get().getThemeList orderby element.Name select element; foreach (ThemeOpenGL t in temp) { comboBox.Items.Add(t.Name); } ThemeOpenGL tempTheme = DrawingSheetAvatarViewModel.Get().actualTheme; comboBox.SelectedIndex = comboBox.Items.IndexOf(tempTheme.Name); this.ResizeMode = ResizeMode.NoResize; jointDetPanel.Width = jointInnPanel.Width = bonesDetPanel.Width = bonesInnPanel.Width = (this.Width - 15) / 2; // Real size of the inner window soundbarColor.Width = 300; }
void worker_ProgressChanged(object sender, ProgressChangedEventArgs e) { // if the replay has faces, it displays the face plus the skeleton // and it takes two screenshot because during a recording with facetracking on it records two time less skeletons if (ReplayAvatar.faceTracking) { DrawingSheetAvatarViewModel.Get().drawFaceInReplay = true; DrawingSheetAvatarViewModel.Get().drawFace(ReplayAvatar.SkeletonList[e.ProgressPercentage].Item3.depthPointsList, ReplayAvatar.SkeletonList[e.ProgressPercentage].Item3.colorPointsList, ReplayAvatar.SkeletonList[e.ProgressPercentage].Item3.faceTriangles); DrawingSheetAvatarViewModel.Get().skToDrawInReplay = ReplayAvatar.SkeletonList[e.ProgressPercentage].Item2; ReplayViewModel.Get().currentFeedbackList = ReplayViewModel.ListFeedbacks[e.ProgressPercentage]; DrawingSheetAvatarViewModel.Get().draw(this, new EventArgs()); avatarVideoStreamWriter.WriteVideoFrame(DrawingSheetAvatarViewModel.Get().GrabScreenshot()); avatarVideoStreamWriter.WriteVideoFrame(DrawingSheetAvatarViewModel.Get().GrabScreenshot()); } // else it displays just the skeleton and takes one screenshot else { // it changes the current skeleton to draw, next it draws, grabs a screenshot and writes on the video DrawingSheetAvatarViewModel.Get().skToDrawInReplay = ReplayAvatar.SkeletonList[e.ProgressPercentage].Item2; ReplayViewModel.Get().currentFeedbackList = ReplayViewModel.ListFeedbacks[e.ProgressPercentage]; DrawingSheetAvatarViewModel.Get().draw(this, new EventArgs()); avatarVideoStreamWriter.WriteVideoFrame(DrawingSheetAvatarViewModel.Get().GrabScreenshot()); } // it changes the value for the progressBar ExportProgressBar.Value = e.ProgressPercentage; //if it's the last one it closes the video, the view and opens a messageBox to inform the user that is complete and the localization of the file if (e.ProgressPercentage == lengthSkeletonList) { avatarVideoStreamWriter.Close(); Close(); new MessageBoxPerso("Export avatar video", "Export complete\nThe video is located in " + ReplayViewModel.Get().folderPath).ShowDialog(); } }
/// <summary> /// Change the view according to the selected mode /// </summary> /// <param name="mode"></param> public void ChangeMode(SheetMode mode) { switch (mode) { case SheetMode.AvatarMode: this.Show3DSheet(); sheet = DrawingSheetAvatarViewModel.Get(this); MyImage.Source = sheet.getImage(); this.mode = SheetMode.AvatarMode; break; case SheetMode.StreamMode: this.Show2DSheet(); sheet = DrawingSheetStreamViewModel.Get(this); MyImage.Source = sheet.getImage(); this.mode = SheetMode.StreamMode; break; default: //TODO break; } this.DataContext = sheet; }
private void CheckBoxFF_Unchecked(object sender, RoutedEventArgs e) { DrawingSheetAvatarViewModel.Get().diplayFaceFeedback = true; }
/// <summary> /// Lauch the detection of the agitation of a joint. /// </summary> /// <param name="sk">Skeleton containing the joint.</param> /// <param name="j">Joint to observe.</param> /// <remarks>Author: Clement Michard</remarks> /// Modified by Baptiste Germond, changing to counting the total of frame to do less calcul /// And deactivating the agitation of the legs when not tracked private static void agitationJoint(Skeleton sk, JointType j) { if (sk.Joints[j].TrackingState == JointTrackingState.Tracked) { /*Ensure that if the leg are not tracked it will not count them in the agitation method*/ if (!(DrawingSheetAvatarViewModel.Get().LegTracked == false && (sk.Joints[j].JointType == JointType.HipCenter //|| sk.joints[j].JointType == JointType.HipLeft //|| sk.Joints[j].JointType == JointType.HipRight || sk.Joints[j].JointType == JointType.KneeLeft || sk.Joints[j].JointType == JointType.KneeRight))) { //If we record the performance and the List conting the agitation of the joint has not the joint observe if (rec && !agitNotAgit.Keys.Contains(j)) { //We create the entry in the List agitNotAgit[j] = new List <int>(); } //If the dictionary don't contain the joint observed if (!agitation.ContainsKey(j)) { //We create the new Agitation and put it in the Dictionary agitation[j] = new Agitation(j); } //Adding the position of the joint agitation[j].Enqueue(Geometry.refKinectToSkeleton(new Point3D(sk.Joints[j].Position), sk)); if (agitation[j].Count == agitation[j].time * KINECT_RATE) { //Return wether the joint is too agitated or not bool agitated = agitation[j].tooAgitated(); //If we are recoring if (rec) { if (j == JointType.HandLeft)//We had to choose one joint to count only one time each frame { //Counting the number of frame recorded nbFrameRecorded++; } if (!agitNotAgit[j].Contains((int)(Tools.getStopWatch() / 100)) && agitated) { //Adding the time where the joint was agitated during the recording agitNotAgit[j].Add((int)(Tools.getStopWatch() / 100)); } } //If the joint is too agitated if (!tooAgitatedJoints.Contains(j) && agitated) { //Adding it to the List and raising the feedback tooAgitatedJoints.Add(j); agitationEvent(j, new InstantFeedback(tooAgitatedText)); feedAg = true; } //If not agitated else if (tooAgitatedJoints.Contains(j) && !agitated) { //Removing it from the list tooAgitatedJoints.Remove(j); //If the list is empty we stop the feedback if (tooAgitatedJoints.Count == 0) { feedAg = false; } } // Somehow this is useful for the agitation icon to be displayed correctly during replays else if (agitated) { agitationEvent(j, new InstantFeedback(tooAgitatedText)); } // Recording of the values necessary for the .csv file if (rec && j == JointType.HandLeft) { if (feedAg) { agitationRecord.Add(Tools.getStopWatch() / 1000.0, 1); } else { agitationRecord.Add(Tools.getStopWatch() / 1000.0, 0); } } } } } // If a joint is no longer tracked, we consider it as "not agitated" else { tooAgitatedJoints.Remove(j); //If the list is empty we stop the feedback if (tooAgitatedJoints.Count == 0) { feedAg = false; } } }
private void skeletonOperations(AllFramesReadyEventArgs e) { Skeleton[] skeletons; Skeleton watchedSkeleton = null; SkeletonFrame skeletonFrame = null; try { skeletonFrame = e.OpenSkeletonFrame(); if (skeletonFrame == null) { return; } skeletons = new Skeleton[skeletonFrame.SkeletonArrayLength]; skeletonFrame.CopySkeletonDataTo(skeletons); watchedSkeleton = getTrackedSkeleton(skeletons, trackClosest(skeletons)); if (watchedSkeleton != null) { skeletonUpdated(this, new SkeletonEventArgs(watchedSkeleton)); // Give each tracker the updated frame. if (Tools.allJointsTracked(watchedSkeleton)) { if (Gesture.compare) { Gesture.testCompare(watchedSkeleton); } if (Posture.compare) { Posture.testCompare(watchedSkeleton); } } if (Agitation.detect) { Agitation.testAgitation(watchedSkeleton); } if (HandsRaised.compare) { HandsRaised.testCompare(watchedSkeleton); } if (HandsJoined.detect) { HandsJoined.startDetection(watchedSkeleton); } if (EmotionRecognition.detect) { EmotionRecognition.EmotionRecognizer(); } if (ArmsWide.compare) { ArmsWide.testCompare(watchedSkeleton); } if (ArmsCrossed.compare) { ArmsCrossed.testCompare(watchedSkeleton); } if (HandsInPocket.compare) //experimental { HandsInPocket.testCompare(watchedSkeleton); } /*Experimental movement to test the training*/ if (DrawingSheetAvatarViewModel.Get().isTraining) { if (TrainingWithAvatarViewModel.canBeInterrupted) { if (String.Compare(TrainingWithAvatarViewModel.AvatarGesture, "WavingTraining") == 0) { TrainingWithAvatarViewModel._gesture.Update(watchedSkeleton); } if (String.Compare(TrainingWithAvatarViewModel.AvatarGesture, "HandTraining") == 0) { TrainingWithAvatarViewModel._handgesture.Update(watchedSkeleton); } if (String.Compare(TrainingWithAvatarViewModel.AvatarGesture, "PowerTraining") == 0) { TrainingWithAvatarViewModel._powergesture.Update(watchedSkeleton); } if (String.Compare(TrainingWithAvatarViewModel.AvatarGesture, "WelcomeTraining") == 0) { TrainingWithAvatarViewModel._welcomegesture.Update(watchedSkeleton); } if (String.Compare(TrainingWithAvatarViewModel.AvatarGesture, "SaluteTraining") == 0) { TrainingWithAvatarViewModel._salutegesture.Update(watchedSkeleton); } if (String.Compare(TrainingWithAvatarViewModel.AvatarGesture, "HypeTraining") == 0) { TrainingWithAvatarViewModel._hypegesture.Update(watchedSkeleton); } if (String.Compare(TrainingWithAvatarViewModel.AvatarGesture, "FaceTraining") == 0) { TrainingWithAvatarViewModel._facegesture.Update(watchedSkeleton); } } } if (KinectDevice.useAutoElevation) { ClippedEdgesElevationChange(watchedSkeleton); } } }finally{ if (skeletonFrame != null) { skeletonFrame.Dispose(); } } }
// Main form load event handler private void glControl_Load(object sender, EventArgs e) { DrawingSheetAvatarViewModel.Get(this).init3DScene(); loaded = true; }
public void OkTheme() { DrawingSheetAvatarViewModel.Get().modifColorOpenGL(comboBox.SelectedItem.ToString()); this.Close(); }