Exemplo n.º 1
0
        public static void AddImage(string person, string emotion, int frame)
        {
            DirectoryInfo taskDirectory = new DirectoryInfo(PathHelper.FrontalSamplesPath(person));
            var           taskFiles     = taskDirectory.GetFiles("*.jpeg").Where(p => p.Name.StartsWith(frame + "_"));

            if (taskFiles.Count() > 0)
            {
                Dictionary <string, int> emotions = ImageDisplay.GetEmotionDictionary();
                var first = taskFiles.ToArray()[0];
                File.Copy(first.FullName, PathHelper.PersonTrainPath(person) + emotions[emotion] + "_" + frame + ".jpeg");
            }
        }
Exemplo n.º 2
0
        public static Dictionary <string, int> GetTimeStamps(string person)
        {
            Dictionary <string, int> timestamps = new Dictionary <string, int>();

            if (!File.Exists(PathHelper.TimeStampsPath(person)))
            {
                return(null);
            }
            // INITIAL TIME STAMPS
            foreach (var emotion in ImageDisplay.GetEmotionDictionary())
            {
                timestamps[emotion.Key] = 0;
            }

            string fileString = File.ReadAllLines(PathHelper.TimeStampsPath(person))[0];
            Dictionary <string, double[]> dictionary = JsonConvert.DeserializeObject
                                                           (fileString, typeof(Dictionary <string, double[]>)) as Dictionary <string, double[]>;

            foreach (var item in dictionary)
            {
                timestamps[item.Key] = ( int )item.Value[0];
            }

            // NEW TIME STAMPS
            DirectoryInfo taskDirectory = new DirectoryInfo(PathHelper.PersonTrainPath(person));

            FileInfo[] files = taskDirectory.GetFiles("*.jpeg");
            Dictionary <string, int> emotionDictionary = ImageDisplay.GetEmotionDictionary();

            foreach (FileInfo file in files)
            {
                string[] emotion_frame = file.Name.Split('_');
                string   emotion       = emotionDictionary.FirstOrDefault(
                    x => x.Value == Int32.Parse(emotion_frame[0]))
                                         .Key;
                timestamps[emotion] = Int32.Parse(emotion_frame[1].Replace(".jpeg", ""));
            }

            return(timestamps);
        }
Exemplo n.º 3
0
        private void DisplayEmotion(object sender = null, RoutedEventArgs e = null)
        {
            if (!validPerson)
            {
                return;
            }

            if (sender != null)
            {
                Button button = sender as Button;
                CleanWindow();
                button.Background    = Brushes.LightSkyBlue;;
                currentEmotion       = (button).Name.ToString();
                emotionLabel.Content = currentEmotion.Replace("sample", "");
                frameModifier        = 0;
            }

            if (!emoteDictionary.ContainsKey(currentEmotion))
            {
                frame = frameModifier;
            }
            else
            {
                frame = emoteDictionary[currentEmotion] + frameModifier;
            }

            imageExists = ImageDisplay.ImageExists(person, currentEmotion, frame);
            if (imageExists)
            {
                removeSample.Visibility = Visibility.Visible;
                addSample.Visibility    = Visibility.Hidden;
            }
            else
            {
                removeSample.Visibility = Visibility.Hidden;
                addSample.Visibility    = Visibility.Visible;
            }
            Display.Source     = ImageDisplay.GetImage(person, frame);
            frameLabel.Content = frame;
        }
Exemplo n.º 4
0
        public static void RemoveImage(string person, string emotion, int frame)
        {
            Dictionary <string, int> emotions = ImageDisplay.GetEmotionDictionary();

            File.Delete(PathHelper.PersonTrainPath(person) + emotions[emotion] + "_" + frame + ".jpeg");
        }