Esempio n. 1
0
        public MainWindow()
        {
            m_imagePath = "";
            InitializeComponent();

            m_emotionsQueue  = new Queue <CalcScores>();
            m_averageEmotion = new CalcScores();
            m_player         = new WindowsMediaPlayer();

            m_player.settings.autoStart = false;

            Binding binding_1 = new Binding("SelectedValue");

            binding_1.Source = VideoDevicesComboBox;
            WebcamCtrl.SetBinding(Webcam.VideoDeviceProperty, binding_1);

            m_picturesDefaultPath = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);

            WebcamCtrl.ImageDirectory = m_picturesDefaultPath;
            m_picturesDefaultPath    += @"\snapshot.jpg";
            WebcamCtrl.FrameRate      = 30;
            WebcamCtrl.FrameSize      = new System.Drawing.Size(640, 480);

            var vidDevices = EncoderDevices.FindDevices(EncoderDeviceType.Video);

            VideoDevicesComboBox.ItemsSource   = vidDevices;
            VideoDevicesComboBox.SelectedIndex = 0;

            startCapturing();
            scan();
        }
Esempio n. 2
0
        private async void scan()
        {
            Emotion[] emotionResult = await UploadAndDetectEmotions();

            LogEmotionResult(emotionResult);
            Scores emotion = selectEmotion(emotionResult);

            if (emotion == null)
            {
                analysisResult.Content = "No emotion detected";
                return;
            }

            getBestValue(emotion, true);
            CalcScores cScore = new CalcScores(emotion);

            int n = m_emotionsQueue.Count;

            if (m_emotionsQueue.Count < m_maxEmotions)
            {
                m_averageEmotion = n * m_averageEmotion * (1 / (n + 1)) + cScore * (1 / (n + 1));
            }
            else
            {
                m_averageEmotion = m_averageEmotion + m_emotionsQueue.Peek() * (-1 / n) + cScore * (1 / n);
                m_emotionsQueue.Dequeue();
            }
            m_emotionsQueue.Enqueue(cScore);
        }