Пример #1
0
 public async Task <int> Start(VideoExecution videoExecution, RuntimeWindow realTimeVisualizer)
 {
     _runtimeVisual = realTimeVisualizer;
     sampleTime     = 0;
     _EmoClient     = new EmotionClient();
     return(await Task.Factory.StartNew <int>(() => StartExecution(videoExecution)));
 }
Пример #2
0
        public async Task <int> BeginExecution(VideoExecution vid)
        {
            //ExecutionId = await DbLayer.GetExecutionContext(vid);

            video       = vid;
            ExecutionId = await DbLayer.WithDataLayerAsync <int>(async db => await db.GetExecutionContext(vid));

            return(ExecutionId);
        }
Пример #3
0
        public void LoadVideoExecution(VideoExecution videoExecutionInstance)
        {
            playbackMediaElement.Source = new Uri(videoExecutionInstance.FullPath);
            videoExecutionDuration      = videoExecutionInstance.VideoLength;

            //Setup the slider
            playbackSlider.BeginInit();
            playbackSlider.TickFrequency = SamplingRate;
            playbackSlider.Maximum       = (videoExecutionDuration.TotalSeconds / SamplingRate);
            playbackSlider.EndInit();
        }
Пример #4
0
        private static async Task StartExecution()
        {
            var orc = new BasicOrchestrator(1);
            var exe = new VideoExecution
            {
                fileName = "",
                height   = 100,
                width    = 100
            };

            //await orc.Start(exe, null);
        }
Пример #5
0
        public async Task <int> GetExecutionContext(VideoExecution video)
        {
            string query = @"INSERT INTO [emo].[ExecutionInstance] (StartTime, FileName, Width, Height) 
                               VALUES (GETUTCDATE(), @FileName, @Width, @Height);  
                               SELECT CONVERT(int, SCOPE_IDENTITY());";

            var result = await ExecuteScalarAsync <int>(query, false,
                                                        "@FileName", video.FileName,
                                                        "@Width", video.Width,
                                                        "@Height", video.Height);

            return(result);
        }
Пример #6
0
        private int StartExecution(VideoExecution videoExecution)
        {
            int executionId = -1;

            try
            {
                _togglePlay  = true;
                executionId  = _EmoClient.BeginExecution(videoExecution).Result;
                _OrcInstance = Task.Factory.StartNew(() => { CaptureAndSend(); });
            }
            catch (Exception ex)
            {
                throw new Exception("Failed to start the orchestration execution!", ex);
            }
            return(executionId);
        }
Пример #7
0
        private void OpenFile()
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.AddExtension = true;
            ofd.DefaultExt   = "*.*";
            ofd.Filter       = "Media (*.*)|*.*";
            ofd.ShowDialog();

            try
            {
                mediaElement.Source = new Uri(ofd.FileName);
                _videoLoaded        = true;
            }
            catch
            {
                _videoLoaded = false;
                //IGNORE whatever just happened
                return;
            }

            #region setup video execution instance

            string fullPath = mediaElement.Source.ToString();
            int    pos      = fullPath.LastIndexOf("/") + 1;
            string filename = fullPath.Substring(pos, fullPath.Length - pos);

            _videoExecutionInstance = new VideoExecution()
            {
                FileName = filename,
                FullPath = fullPath,
                Height   = (int)mediaElement.ActualHeight,
                Width    = (int)mediaElement.ActualWidth
            };

            _Runtime.Start();

            #endregion
        }
Пример #8
0
        //public async Task<List<EmotionScore>> GetScoresFilteredBy(int something)
        //{
        //    throw new NotImplementedException();
        //}

        public async Task <List <List <EmotionScore> > > GetFullScoreHistory(VideoExecution vid)
        {
            string query = @"   SELECT * FROM [emo].[EmotionScore] ES 
                                JOIN [emo].[ExecutionInstance] EI ON ES.ExecutionId = EI.Id 
                                WHERE FileName LIKE '%" + vid.FileName + @"%'
                                ORDER BY [TimeStamp], [ExecutionId];";

            List <List <EmotionScore> > results  = new List <List <EmotionScore> >();
            List <EmotionScore>         scoreExe = null;

            using (var reader = await this.ExecuteReaderAsync(query, false, "@FileName", vid.FileName))
            {
                int prevExe = 0;
                while (reader.Read())
                {
                    EmotionScore score = new EmotionScore(reader);
                    if (score.executionId != prevExe)
                    {
                        if (prevExe != 0)
                        {
                            results.Add(scoreExe);
                        }

                        scoreExe = new List <EmotionScore>();
                        prevExe  = score.executionId;
                    }
                    scoreExe.Add(score);
                }
                if (scoreExe != null && scoreExe.Count != 0)
                {
                    results.Add(scoreExe);
                }
            }

            return(results);
        }
Пример #9
0
        public async Task StartStopExecution()
        {
            IDataLayer dbAccess = new SQLDataLayer(_connection);
            int        vHeight  = 200;
            int        vWidth   = 200;
            string     vName    = "unitTestName";

            VideoExecution ve = new VideoExecution()
            {
                Height   = vHeight,
                Width    = vWidth,
                FileName = vName
            };

            int executionId = await dbAccess.WithDataLayerAsync <int>(async db => await db.GetExecutionContext(ve));

            var query1 = @"SELECT * FROM [emo].[ExecutionInstance] WHERE Id = @exeId;";

            this.Open();
            using (var reader = await ExecuteReaderAsync(query1, false, "@exeId", executionId))
            {
                if (reader.Read())
                {
                    var fname   = reader["Filename"] as string;
                    var fwidth  = Convert.ToInt32(reader["Width"]);
                    var fheight = Convert.ToInt32(reader["Height"]);

                    Assert.AreEqual(fname, vName);
                    Assert.AreEqual(vHeight, fheight);
                    Assert.AreEqual(vWidth, fwidth);
                }
            }
            this.Close();

            double   scoreValue = 0.5;
            DateTime now        = DateTime.UtcNow;

            EmotionScore score = new EmotionScore()
            {
                startTime = now,
                endTime   = now,
                scores    = new Scores()
                {
                    anger     = scoreValue,
                    contempt  = scoreValue,
                    disgust   = scoreValue,
                    fear      = scoreValue,
                    happiness = scoreValue,
                    neutral   = scoreValue,
                    sadness   = scoreValue,
                    surprise  = scoreValue
                },
                executionId = executionId,
            };

            OrderedDictionary od = new OrderedDictionary();

            od.Add(now, score);

            var finish = await dbAccess.WithDataLayerAsync <bool>(async db => await db.FinishExecution(od, executionId));

            Assert.AreEqual(finish, true);

            var query2 = @"SELECT * FROM [emo].[EmotionScore] WHERE ExecutionId = @exeId ORDER BY TimeStamp ASC;";

            this.Open();
            using (var reader = await this.ExecuteReaderAsync(query2, false, "@exeId", executionId))
            {
                if (reader.Read())
                {
                    var start = Convert.ToDateTime(reader["StartTime"]);
                    var end   = Convert.ToDateTime(reader["EndTime"]);
                    var time  = Convert.ToDateTime(reader["TimeStamp"]);

                    var angerScore = Convert.ToDouble(reader["Anger"]);

                    Assert.AreEqual(angerScore, scoreValue);
                }
            }
            this.Close();
        }
Пример #10
0
 public void ShowPostPlaybackVisualizations(VideoExecution videoExection)
 {
     Task.Factory.StartNew(() => { ShowFinalvisualizationTask(); });
 }