/// <summary> /// 委派所註冊的方法,從雲端回傳的資料,傳送到這方法,比對單字跟臉部辨識的表情 /// </summary> private void SetFaceFeature(String face_feature) { this.FaceInfo.Text = face_feature; //Clear progressbar this.ImageUploadBar.Value = 0; this.ImageUploadBar.Visibility = Visibility.Collapsed; //Firebase上傳照片結果以及次數 if (txtVocabulary.Text != null) { FirebaseUpload.Upload(ActivityTitle, new Photo(txtVocabulary.Text.Trim(), face_feature, 1)); } if (face_feature.ToLower().Contains(vocabulary.Give_Vocabulary(posture_number).ToLower())) { //呼叫成功的方法 Success_Change_word(this, new EventArgs()); } Console.WriteLine(face_feature); //用來檢查是否有包含情感的單字 if (BasicMethod.CheckEmotionWord(vocabulary.Give_Vocabulary(posture_number), face_feature)) { //呼叫成功的方法 Success_Change_word(this, new EventArgs()); } }
private void QRCodeTimer_Tick(object sender, EventArgs e) { ShowScore(); if (QRCodeBitmap == null) { return; } //把ColorFrame的wbData的資料從WriteableBitmap格式,轉成Bitmap格式,才能符合QRcode格式 ZXing.Result result = reader.Decode(BitmapToWriteableBitmap.BitmapFromWriteableBitmap(QRCodeBitmap)); if (result != null) { Console.WriteLine(result.Text); if (vocabulary.Give_Vocabulary(posture_number).ToLower().Contains(result.Text.ToLower())) { Success_Change_word(this, new EventArgs()); Console.WriteLine("成功" + result.Text); FirebaseUpload.Upload(ActivityTitle, "正確", new ORcodeObject(result.Text, txtVocabulary.Text, 1)); } else { SoundPlay.PlaySoundFailed(); Console.WriteLine("失敗" + result.Text); FirebaseUpload.Upload(ActivityTitle, "錯誤", new ORcodeObject(result.Text, txtVocabulary.Text, 1)); } } }
private void QRCodeTimer_Tick(object sender, EventArgs e) { if (QRCodeBitmap == null) { return; } //把ColorFrame的wbData的資料從WriteableBitmap格式,轉成Bitmap格式,才能符合QRcode格式 ZXing.Result result = reader.Decode(BitmapToWriteableBitmap.BitmapFromWriteableBitmap(QRCodeBitmap)); if (result != null) { Console.WriteLine(result.Text); //這邊要檢查 List裡有包含單字的陣列 if (TaskWords.Contains(result.Text)) { ReturnPostureWords returnPostureWords = new ReturnPostureWords() { PostureWords = result.Text }; Success_Change_word(this, returnPostureWords); Console.WriteLine("成功" + result.Text); FirebaseUpload.Upload(ActivityTitle, "正確", new ORcodeObject(result.Text, txtVocabulary.Text, 1)); } else { SoundPlay.PlaySoundFailed(); //System.Windows.Forms.MessageBox.Show(result.Text); Console.WriteLine("失敗" + result.Text); FirebaseUpload.Upload(ActivityTitle, "錯誤", new ORcodeObject(result.Text, txtVocabulary.Text, 1)); } } }
/// <summary> /// 委派所註冊的方法,從雲端回傳的資料,傳送到這方法,比對單字跟臉部辨識的表情 /// </summary> private void SetFaceFeature(String face_feature) { this.FaceInfo.Text = face_feature; //Clear progressbar this.ImageUploadBar.Value = 0; this.ImageUploadBar.Visibility = Visibility.Collapsed; //Firebase上傳照片結果以及次數 if (txtVocabulary.Text != null) { FirebaseUpload.Upload(ActivityTitle, new Photo(txtVocabulary.Text.Trim(), face_feature, 1)); } if (face_feature.ToLower().Contains(vocabulary.Give_Vocabulary(posture_number).ToLower())) { //呼叫成功的方法 Success_Change_word(this, new EventArgs()); } Console.WriteLine(face_feature); //把每一個存在EmotionList裡面的單字拿出來跟臉部辨識比對資料 if (TaskWords != null) { foreach (String List in StorageEmotionWords) { Console.WriteLine("情感單字" + StorageEmotionWords); Success_Change_word(this, BasicMethod.CheckEmotionWord_Sentence(List, face_feature)); } } }
/// <summary> /// 語音辨識事件 /// </summary> private void SpeechRecognized(object sender, SpeechRecognizedEventArgs e) { //if (StopDetect != true) { //Show Sppech Confidence number on screen //Show Sppech Confidence number on screen Speech_Confidence.Content = "Speaking Accuracy" + "\r\n" + e.Result.Confidence.ToString(); //設定語音信度門檻值 if (e.Result.Confidence >= BasicMethod.ConfidenceThreshold) { Console.WriteLine(e.Result.Text); //語音辨識跟單字比對 if (e.Result.Semantics.Value.ToString().ToLower() == vocabulary.Give_StudentsSentence(posture_number).ToLower()) { //Firebase上傳資料 FirebaseUpload.Upload(ActivityTitle, "正確", new Speech(txtVocabulary.Text.Trim(), e.Result.Confidence)); if (Select_Item.SetPeerSentenceGameMode == true) { //新增語音辨識信心度到List SpeechConfidenceList.Add(BasicMethod.GiveSpeechConfidenceScore(e.Result.Confidence)); Console.WriteLine("總分" + TotalTime); Console.WriteLine("語音分數" + BasicMethod.GiveSpeechConfidenceScore(e.Result.Confidence)); } //顯示正確圖示 Speech_Correct.Visibility = Visibility.Visible; //將語音辨識結果設為True Speech_Result = true; //播放正確音效 SoundPlay.PlaySoundCorrect(); //通知事件,只是為了再次呼叫 檢查正確與否的方法,所以PostureWords 設為空值 if (!Speech_Result == false && !Posture_Result == false) { ReturnPostureWords returnPostureWords = new ReturnPostureWords() { PostureWords = "" }; Success_Change_word(this, returnPostureWords); } } else { //如果答錯就記錄到Firebase 但是也要設定門檻才不容易發生誤判 if (txtVocabulary.Text != null || e.Result.Confidence >= 0.35) { //Firebase上傳資料 FirebaseUpload.Upload(ActivityTitle, "錯誤", new Speech(txtVocabulary.Text.Trim(), e.Result.Semantics.Value.ToString(), e.Result.Confidence)); } } } } }
public RankData(String Activity) { InitializeComponent(); this.Activity = Activity; this.Title = Activity; FirebaseUpload.QueryData(Activity, RankList_View); }
/// <summary> /// 判斷成功事件 /// </summary> private void Success_Change_word(object sender, EventArgs e) { if (e != null) { //停止時間 dispatcherGameTimer.Stop(); Posture_Result = true; //姿勢正確會呼叫Success_Change_word,並把姿勢正確的圖示顯示出來 Posture_Correct.Visibility = Visibility.Visible; //播放音效,用執行序來呼叫 PlayCorrectSound(); //把事件傳過來的值拿下來,(Ps.現在傳過來的是一個繼承 EventArgs 的 Class 且裡面包含 PostureWords 欄位) var TargetWords = (e as ReturnPostureWords).PostureWords; Console.WriteLine(TargetWords); //檢查是否包含單字 if (TaskWords.Contains(TargetWords)) { TaskWords.Remove(TargetWords); txtCountWords.Content = (String.Format("剩餘 : {0}", TaskWords.Count.ToString())); Console.WriteLine(TaskWords.Count); //Firebase上傳姿勢資料 FirebaseUpload.Upload(ActivityTitle, txtVocabulary.Text.Trim(), new Posture(txtVocabulary.Text.Trim(), TargetWords, 1)); } //檢查是否都通過 if (!Speech_Result == false && !Posture_Result == false && !Speech_Enable == false && TaskWords.Count == 0) { txtCountWords.Content = ("通過測驗"); Speech_Enable = false; //紀錄遊戲時間分數,以時間當作積分,當遊戲模式啟動 if (Select_Item.SetSentenceGameMode == true) { //把語音辨識信心度當成分數 TotalTime += SpeechConfidenceList.Max(x => x); //做出的動作越快分數越高 TotalTime += GameTimer; FirebaseUpload.Upload_Rakn_Point(Students.StudentsName, RankData.Rank_Interactive, TotalTime); } //Show Sentence this.txtSentence.Visibility = Visibility.Visible; //Hide Example Image this.exampleImage.Visibility = Visibility.Collapsed; Show_Sentence(); } } }
/// <summary> /// 判斷成功事件,姿勢正確會呼叫此方法 /// </summary> private void Success_Change_word(object sender, EventArgs e) { //停止時間 dispatcherGameTimer.Stop(); //姿勢正確會呼叫Success_Change_word,並把姿勢正確的圖示顯示出來 Posture_Correct.Visibility = Visibility.Visible; Posture_Result = true; // 播放音效,用執行序來呼叫 this.Dispatcher.Invoke((Action)(() => { if (PostureSoundStatus != true) { SoundPlay.PlaySoundCorrect(); PostureSoundStatus = true; if (txtVocabulary.Text != null) { //Firebase上傳姿勢資料 FirebaseUpload.Upload(ActivityTitle, new Posture(txtVocabulary.Text.Trim(), 1)); } } })); if (!Speech_Result == false && !Posture_Result == false && !Speech_Enable == false) { //Hide Example Image this.exampleImage.Visibility = Visibility.Collapsed; Speech_Enable = false; //紀錄遊戲時間分數,以時間當作積分,當遊戲模式啟動 if (Select_Item.SetVocabularyGameMode == true) { //把語音辨識信心度當成分數 TotalTime += SpeechConfidenceList.Max(x => x); //做出的動作越快分數越高 TotalTime += GameTimer; Console.WriteLine("姿勢辨識總時間" + TotalTime + "剩餘時間" + GameTimer); FirebaseUpload.Upload_Rakn_Point(Students.StudentsName, RankData.Rank_Vocabulary, TotalTime); } //Show Sentence this.txtSentence.Visibility = Visibility.Visible; //顯示句子 txtSentence.Text = vocabulary.Give_Sentence(posture_number); //需要用微軟的TextToSpeech念出句子,因為Azure Text To Speech 只能調整單一語言 textToSpeech.MicrosoftTextToSpeech(txtSentence.Text.ToString()); //textToSpeech.SpeechMethod(txtSentence.Text.ToString()); txtDetection.Content = "Example Sentence"; } }
/// <summary> /// 判斷成功事件,姿勢正確會呼叫此方法 /// </summary> private void Success_Change_word(object sender, EventArgs e) { //停止時間 dispatcherGameTimer.Stop(); //姿勢正確會呼叫Success_Change_word,並把姿勢正確的圖示顯示出來 Posture_Correct.Visibility = Visibility.Visible; Posture_Result = true; // 播放音效,用執行序來呼叫 this.Dispatcher.Invoke((Action)(() => { if (PostureSoundStatus != true) { SoundPlay.PlaySoundCorrect(); PostureSoundStatus = true; if (txtVocabulary.Text != null) { //Firebase上傳姿勢資料 FirebaseUpload.Upload(ActivityTitle, new Posture(txtVocabulary.Text.Trim(), 1)); } } })); if (!Speech_Result == false && !Posture_Result == false && !Speech_Enable == false) { //Hide Example Image this.exampleImage.Visibility = Visibility.Collapsed; Speech_Enable = false; //傳給對方讓它顯示句子 sokcet_Connect.SendDataToServer((int)BasicMethod.TriggerButtonCode.Successful); // 紀錄遊戲時間分數,以時間當作積分,當遊戲模式啟動 if (Select_Item.SetPeerVocabularyGameMode == true) { //把語音辨識信心度當成分數 TotalTime += SpeechConfidenceList.Max(x => x); //做出的動作越快分數越高 TotalTime += GameTimer; Console.WriteLine("姿勢辨識總時間" + TotalTime + "剩餘時間" + GameTimer); //回存遊戲分數 FirebaseUpload.Upload_Rakn_Point(Students.StudentsName, RankData.Rank_PeerVocabulary, TotalTime); } ShowSentence(); } }
/// <summary> /// 委派所註冊的方法,從雲端回傳的資料,傳送到這方法,比對單字跟臉部辨識的表情 /// </summary> private void SetFaceFeature(String face_feature) { Console.WriteLine(face_feature); this.FaceInfo.Content = face_feature; //Clear progressbar this.ImageUploadBar.Value = 0; this.ImageUploadBar.Visibility = Visibility.Collapsed; //Firebase上傳照片結果以及次數 if (txtVocabulary.Text != null) { FirebaseUpload.Upload(ActivityTitle, new Photo(txtVocabulary.Text.Trim(), face_feature, 1)); } if (TaskWords != null) { foreach (String List in StorageEmotionWords) { Console.WriteLine("單字" + StorageEmotionWords); Success_Change_word(this, BasicMethod.CheckEmotionWord_Sentence(List, face_feature)); } } if (face_feature.Contains("anger")) { //呼叫成功的方法 //Success_Change_word(this, new EventArgs()); ReturnPostureWords returnPostureWords = new ReturnPostureWords() { PostureWords = "Anger" }; //Success_Change_word(this, returnPostureWords); } else if (face_feature.Contains("surprise")) { //呼叫成功的方法 //Success_Change_word(this, new EventArgs()); ReturnPostureWords returnPostureWords = new ReturnPostureWords() { PostureWords = "Startled" }; //Success_Change_word(this, returnPostureWords); } Console.WriteLine(face_feature); }
/// <summary> /// 判斷成功事件 /// </summary> private void Success_Change_word(object sender, EventArgs e) { if (e != null) { //停止時間 dispatcherGameTimer.Stop(); //把事件傳過來的值拿下來,(Ps.現在傳過來的是一個繼承 EventArgs 的 Class 且裡面包含 PostureWords 欄位) var TargetWords = (e as ReturnPostureWords).PostureWords; Console.WriteLine(TargetWords); if (TaskWords.Contains(TargetWords)) { //Firebase上傳姿勢資料 FirebaseUpload.Upload(ActivityTitle, txtVocabulary.Text.Trim(), new Posture(txtVocabulary.Text.Trim(), TargetWords, 1)); //移除答對單字 TaskWords.Remove(TargetWords); //顯示剩下幾個單字 txtCountWords.Content = (String.Format("Target : {0}", TaskWords.Count.ToString())); Console.WriteLine(TaskWords.Count); // 播放音效,用執行序來呼叫 this.Dispatcher.Invoke((Action)(() => { SoundPlay.PlaySoundCorrect(); })); if (TaskWords.Count == 0) { //姿勢正確會呼叫Success_Change_word,並把姿勢正確的圖示顯示出來 Posture_Correct.Visibility = Visibility.Visible; Posture_Result = true; //txtCountWords.Content = ("答對------輪到對方回答"); } } else { return; } } if (!Speech_Result == false && !Posture_Result == false && !Speech_Enable == false) { //Show Sentence this.txtSentence.Visibility = Visibility.Visible; //Hide Example Image this.exampleImage.Visibility = Visibility.Collapsed; Speech_Enable = false; //把語音辨識信心度當成分數 TotalTime += SpeechConfidenceList.Max(x => x); //做出的動作越快分數越高 TotalTime += GameTimer; Console.WriteLine("姿勢辨識總時間" + TotalTime + "剩餘時間" + GameTimer); //回存遊戲分數 FirebaseUpload.Upload_Rakn_Point(Students.StudentsName, RankData.Rank_PeerInteractive, TotalTime); //把姿勢索引傳過去 sokcet_Connect.SendDataToServer(posture_number + 1); } }
/// <summary> /// 判斷成功事件,姿勢正確會呼叫此方法 /// </summary> private void Success_Change_word(object sender, EventArgs e) { //停止時間 dispatcherGameTimer.Stop(); //姿勢正確會呼叫Success_Change_word,並把姿勢正確的圖示顯示出來 Posture_Correct.Visibility = Visibility.Visible; Posture_Result = true; //把事件傳過來的值拿下來,(Ps.現在傳過來的是一個繼承 EventArgs 的 Class 且裡面包含 PostureWords 欄位) var TargetWords = (e as ReturnPostureWords).PostureWords; // 播放音效,用執行序來呼叫 this.Dispatcher.Invoke((Action)(() => { if (PostureSoundStatus != true) { SoundPlay.PlaySoundCorrect(); PostureSoundStatus = true; if (txtVocabulary.Text != null) { //Firebase上傳姿勢資料 //FirebaseUpload.Upload(ActivityTitle, new Posture(txtVocabulary.Text.Trim(), 1)); } } })); //檢查是否包含單字 if (TaskWords.Contains(TargetWords)) { TaskWords.Remove(TargetWords); txtCountWords.Content = (String.Format("Target : {0}", TaskWords.Count.ToString())); Console.WriteLine(TaskWords.Count); //Firebase上傳姿勢資料 FirebaseUpload.Upload(ActivityTitle, txtVocabulary.Text.Trim(), new Posture(txtVocabulary.Text.Trim(), TargetWords, 1)); } //檢查是否都通過 if (!Speech_Result == false && !Posture_Result == false && !Speech_Enable == false && TaskWords.Count == 0) { //Hide Example Image this.exampleImage.Visibility = Visibility.Collapsed; Speech_Enable = false; //傳給對方讓它顯示句子 sokcet_Connect.SendDataToServer((int)BasicMethod.TriggerButtonCode.Successful); // 紀錄遊戲時間分數,以時間當作積分,當遊戲模式啟動 if (Select_Item.SetPeerSentenceGameMode == true) { //把語音辨識信心度當成分數 TotalTime += SpeechConfidenceList.Max(x => x); //做出的動作越快分數越高 TotalTime += GameTimer; Console.WriteLine("姿勢辨識總時間" + TotalTime + "剩餘時間" + GameTimer); //回存遊戲分數 FirebaseUpload.Upload_Rakn_Point(Students.StudentsName, RankData.Rank_PeerInteractive, TotalTime); } ShowSentence(); } }
private void InitializeScore_Click(object sender, RoutedEventArgs e) { FirebaseUpload.InitializeScore(Activity, 0); }