/// <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());
            }
        }
        /// <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));
                        }
                    }
                }
            }
        }
        /// <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));
                }
            }
        }
        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            //註銷掉事件
            bodyFrameReader.FrameArrived    -= BodyFrameReader_FrameArrived;
            _reader.MultiSourceFrameArrived -= _reader_MultiSourceFrameArrived;
            poseture.Poseture_List          -= Success_Change_word;
            dispatcherTimer.Tick            -= DispatcherTimer_Tick;
            dispatcherGameTimer.Tick        -= GameTimer_Tick;
            QRcodeTimer.Tick -= QRCodeTimer_Tick;

            //Stop Text To Speech
            textToSpeech.SpeechPause();

            //Stop SoundPlay
            SoundPlay.PlayStop();

            //停止偵測QRCode
            QRcodeTimer.Stop();

            //暫停拍照倒數時間
            dispatcherTimer.Stop();

            //將音效的狀態設定為初始值
            PostureSoundStatus = false;

            if (_reader != null)
            {
                _reader.Dispose();
                _reader = null;
            }

            if (bodyFrameReader != null)
            {
                bodyFrameReader.Dispose();
                bodyFrameReader = null;
            }

            if (null != this.convertStream)
            {
                this.convertStream.SpeechActive = false;
            }

            if (null != this.speechEngine)
            {
                this.speechEngine.SpeechRecognized          -= this.SpeechRecognized;
                this.speechEngine.SpeechRecognitionRejected -= this.SpeechRejected;
                this.speechEngine.RecognizeAsyncStop();
            }

            //用來判斷該呼叫哪個主頁面
            BasicMethod.CallMainWindow();
        }
        public PeerMainWidnow()
        {
            InitializeComponent();

            InitializeKinect();

            InitializeHandControl();

            InitializeEventHander();

            txtStudentsName.Content = Students.StudentsName;

            BasicMethod.Init_Mode();
        }
Example #6
0
        /// <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);
        }
Example #7
0
        public MainWindow()
        {
            InitializeComponent();

            InitializeKinect();

            InitializeHandControl();

            InitializeEventHander();

            BasicMethod.Init_Mode();

            Height = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width;
            Width  = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height;
            txtStudentsName.Content = Students.StudentsName;
        }