public LogEmotionResult ( |
||
emotionResult | ||
Résultat | void |
private async void LoadImageButton_Click(object sender, RoutedEventArgs e) { string urlString = URLTextBox.Text; Uri uri = new Uri(urlString, UriKind.Absolute); MainWindow window = (MainWindow)Application.Current.MainWindow; string subscriptionKey = window.ScenarioControl.SubscriptionKey; window.ScenarioControl.ClearLog(); // // Load image from URL for information purpose. This is not used in emotion detection // var bitmapSource = new BitmapImage(); bitmapSource.BeginInit(); bitmapSource.UriSource = uri; bitmapSource.EndInit(); _emotionDetectionUserControl.ImageUri = uri; _emotionDetectionUserControl.Image = bitmapSource; _detectionStatus.Text = "Detecting..."; Emotion[] emotionResult = await UploadAndDetectEmotions(urlString); _detectionStatus.Text = "Detection Done"; // // Log detection result in the log window // window.Log(""); window.Log("Detection Result:"); window.LogEmotionResult(emotionResult); _emotionDetectionUserControl.Emotions = emotionResult; }
private async void LoadImageButton_Click(object sender, RoutedEventArgs e) { MainWindow window = (MainWindow)Application.Current.MainWindow; Microsoft.Win32.OpenFileDialog openDlg = new Microsoft.Win32.OpenFileDialog(); openDlg.Filter = "JPEG Image(*.jpg)|*.jpg"; bool?result = openDlg.ShowDialog(window); if (!(bool)result) { return; } string imageFilePath = openDlg.FileName; Uri fileUri = new Uri(imageFilePath); BitmapImage bitmapSource = new BitmapImage(); bitmapSource.BeginInit(); bitmapSource.CacheOption = BitmapCacheOption.None; bitmapSource.UriSource = fileUri; bitmapSource.EndInit(); _emotionDetectionUserControl.ImageUri = fileUri; _emotionDetectionUserControl.Image = bitmapSource; // // Enviando a imagem // window.ScenarioControl.ClearLog(); _detectionStatus.Text = "Detectando..."; //Crie envio da imagem _detectionStatus.Text = "Finalizada..."; // // Log // window.Log(""); window.Log("Detection Result:"); window.LogEmotionResult(emotionResult); _emotionDetectionUserControl.Emotions = emotionResult; }
private async void LoadImageButton_Click(object sender, RoutedEventArgs e) { MainWindow window = (MainWindow)Application.Current.MainWindow; Microsoft.Win32.OpenFileDialog openDlg = new Microsoft.Win32.OpenFileDialog(); openDlg.Filter = "JPEG Image(*.jpg)|*.jpg"; bool?result = openDlg.ShowDialog(window); if (!(bool)result) { return; } string imageFilePath = openDlg.FileName; Uri fileUri = new Uri(imageFilePath); BitmapImage bitmapSource = new BitmapImage(); bitmapSource.BeginInit(); bitmapSource.CacheOption = BitmapCacheOption.None; bitmapSource.UriSource = fileUri; bitmapSource.EndInit(); _emotionDetectionUserControl.ImageUri = fileUri; _emotionDetectionUserControl.Image = bitmapSource; // // Create EmotionServiceClient and detect the emotion with URL // window.ScenarioControl.ClearLog(); _detectionStatus.Text = "Detecting..."; Emotion[] emotionResult = await UploadAndDetectEmotions(imageFilePath); _detectionStatus.Text = "Detection Done"; // // Log detection result in the log window // window.Log(""); window.Log("Detection Result:"); window.LogEmotionResult(emotionResult); _emotionDetectionUserControl.Emotions = emotionResult; }
private async void LoadImageButton_Click(object sender, RoutedEventArgs e) { MainWindow window = (MainWindow)Application.Current.MainWindow; Microsoft.Win32.OpenFileDialog openDlg = new Microsoft.Win32.OpenFileDialog(); openDlg.Filter = "JPEG Image(*.jpg)|*.jpg"; bool?result = openDlg.ShowDialog(window); if (!(bool)result) { return; } string imageFilePath = openDlg.FileName; Uri fileUri = new Uri(imageFilePath); BitmapImage bitmapSource = new BitmapImage(); bitmapSource.BeginInit(); bitmapSource.CacheOption = BitmapCacheOption.None; bitmapSource.UriSource = fileUri; bitmapSource.EndInit(); _emotionDetectionUserControl.ImageUri = fileUri; _emotionDetectionUserControl.Image = bitmapSource; // // Create EmotionServiceClient and detect the emotion with URL // window.ScenarioControl.ClearLog(); _detectionStatus.Text = "Detecting..."; Emotion[] emotionResult = await UploadAndDetectEmotions(imageFilePath); _detectionStatus.Text = "Detection Done"; // // Log detection result in the log window // window.Log(""); window.Log("Detection Result:"); window.LogEmotionResult(emotionResult); _emotionDetectionUserControl.Emotions = emotionResult; // var success = await System.Windows.Launcher.LaunchUriAsync(uri); //resultDisplay[0] = new EmotionResultDisplay { EmotionString = "Anger", Score = emotion.Scores.Anger }; //resultDisplay[1] = new EmotionResultDisplay { EmotionString = "Contempt", Score = emotion.Scores.Contempt }; //resultDisplay[2] = new EmotionResultDisplay { EmotionString = "Disgust", Score = emotion.Scores.Disgust }; //resultDisplay[3] = new EmotionResultDisplay { EmotionString = "Fear", Score = emotion.Scores.Fear }; //resultDisplay[4] = new EmotionResultDisplay { EmotionString = "Happiness", Score = emotion.Scores.Happiness }; //resultDisplay[5] = new EmotionResultDisplay { EmotionString = "Neutral", Score = emotion.Scores.Neutral }; //resultDisplay[6] = new EmotionResultDisplay { EmotionString = "Sadness", Score = emotion.Scores.Sadness }; //resultDisplay[7] = new EmotionResultDisplay { EmotionString = "Surprise", Score = emotion.Scores.Surprise }; float fAnger = emotionResult[0].Scores.Anger; float fSadness = emotionResult[0].Scores.Sadness; float fHappiness = emotionResult[0].Scores.Happiness; string sSongURL = ""; if (fAnger > 0.5) { // 許如芸 生氣 sSongURL = "kkbox://play_song_849314"; } if (fSadness > 0.5) { // 陳珊妮 如同悲傷被下載了兩次 sSongURL = "kkbox://play_song_77706479"; } if (fHappiness > 0.5) { // Happy Birthday 寶兒 (BoA) 千顏兒語 (THE FACE) sSongURL = "kkbox://play_song_1601466"; } // var uri = "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe"; var uri = "D:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe"; System.Diagnostics.Process.Start(uri, sSongURL); }