public async void GetTestFace() { TestFace tf = new TestFace(); string personImageDir = @"C:\Users\v-altsai\Pictures\Original"; string[] ImagePathArray = Directory.GetFiles(personImageDir, "*.jpg"); this.IdentifyState = "Analysis your face..."; loading_animation.Visibility = Visibility.Visible; Console.WriteLine("Call Face API"); string s = await tf.Testpicture(ImagePathArray[0]); JSONHelper helper = new JSONHelper(); SendMessageToCloud sc = new SendMessageToCloud(); People p = new People(); p = helper.ConvertJSonToObject <People>(s.ToString()); identify_name = p.Name; identify_Gender = p.Gender; identify_Age = p.Age; identify_Emotion = p.Emotion; identify_EmotionScoreList = p.Emotionlistscore; foreach (KeyValuePair <string, float> row in identify_EmotionScoreList) { Console.WriteLine("Key: " + row.Key + " Value: " + row.Value); } if (p.Name == "none") { this.IdentifyState = "You aren't permitted to access!"; } else { sc.sendWindTurbineMessageToCloudAsync(identify_name, identify_Age, identify_Gender, identify_Emotion, identify_EmotionScoreList, deviceConnectionString); this.IdentifyState = "Hi " + p.Name + ",\nYou are permitted to access!"; } this.PersonName = "Name: " + p.Name + "\nGender: " + p.Gender + "\nAge: " + p.Age + "\nEmotion: " + p.Emotion; viewmode = true; if (viewmode) { BackGround_Screen.Source = bg_pool; badge_Screen.Source = badge[0]; Load_FigureImage(); loading_animation.Visibility = Visibility.Collapsed; Figure_Screen.Visibility = Visibility.Visible; BackGround_Screen.Visibility = Visibility.Visible; badge_Screen.Visibility = Visibility.Visible; viewmode = false; Delete dd = new Delete(); dd.DeletleImage(personImageDir); } }
public async void CaptureImg() { if (this.colorBitmap == null) { } // create a png bitmap encoder which knows how to save a .png file BitmapEncoder encoder = new PngBitmapEncoder(); // create frame from the writable bitmap and add to encoder encoder.Frames.Add(BitmapFrame.Create(this.colorBitmap)); string time = System.DateTime.Now.ToString("hh'-'mm'-'ss", CultureInfo.CurrentUICulture.DateTimeFormat); string myPhotos = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures); string path = Path.Combine(myPhotos, "KinectScreenshot-Color-" + time + ".jpg"); // write the new file to disk // FileStream is IDisposable try { // FileStream is IDisposable using (FileStream fs = new FileStream(path, FileMode.Create)) { encoder.Save(fs); fs.Close(); } this.StatusText = string.Format(Properties.Resources.SavedScreenshotStatusTextFormat, path); } catch (IOException) { this.StatusText = string.Format(Properties.Resources.FailedScreenshotStatusTextFormat, path); } // this.StatusText = string.Format(Properties.Resources.SavedScreenshotStatusTextFormat, path); System.Console.WriteLine(path); HeadRandom = System.IO.Path.GetRandomFileName().Split(new string[] { "." }, StringSplitOptions.RemoveEmptyEntries); TestFace tf = new TestFace(); if (path != null) { this.IdentifyState = "Analysis your face..."; loading_animation.Visibility = Visibility.Visible; Console.WriteLine("Call Face API"); var s = await tf.Testpicture(path); JSONHelper helper = new JSONHelper(); People p = new People(); p = helper.ConvertJSonToObject <People>(s.ToString()); identify_name = p.Name; identify_Gender = p.Gender; identify_Age = p.Age; identify_Emotion = p.Emotion; identify_EmotionScoreList = p.Emotionlistscore; foreach (KeyValuePair <string, float> row in identify_EmotionScoreList) { Console.WriteLine("Key: " + row.Key + " Value: " + row.Value); } if (p.Name == "none") { this.IdentifyState = "You aren't permitted to access!"; } else { this.IdentifyState = "Hi " + p.Name + ",\nYou are permitted to access!"; } this.PersonName = "Name: " + p.Name + "\nGender: " + p.Gender + "\nAge: " + p.Age + "\nEmotion: " + p.Emotion; viewmode = true; if (viewmode) { BackGround_Screen.Source = bg_pool; badge_Screen.Source = badge[0]; Load_FigureImage(); loading_animation.Visibility = Visibility.Collapsed; Figure_Screen.Visibility = Visibility.Visible; BackGround_Screen.Visibility = Visibility.Visible; badge_Screen.Visibility = Visibility.Visible; viewmode = false; } } }