Ejemplo n.º 1
0
        public IActionResult GetWatchInfoCsv(string video, string watch)
        {
            FileInfo f           = new FileInfo(Video.Folder + video + "/" + watch);
            Watch    watchObject = new Watch(f.FullName)
            {
                Video = new Video()
                {
                    Name = video
                }
            };

            var records = watchObject.LoadInfo();

            if (!records.Any())
            {
                return(NotFound());
            }

            List <WatchInfoSpeed> list = WatchInfoSpeed.Compile(watchObject, records);

            using (MemoryStream ms = new MemoryStream())
                using (StreamWriter sw = new StreamWriter(ms))
                    using (CsvWriter writer = new CsvWriter(sw))
                    {
                        writer.WriteHeader <WatchInfoSpeed>();
                        sw.WriteLine();
                        writer.WriteRecords(list);
                        return(Ok(Encoding.UTF8.GetString(ms.ToArray())));
                    }
        }
Ejemplo n.º 2
0
        public IActionResult GetFixationsCsv(string video, string watch)
        {
            FileInfo f           = new FileInfo(Video.Folder + video + "/" + watch);
            Watch    watchObject = new Watch(f.FullName)
            {
                Video = new Video()
                {
                    Name = video
                }
            };

            var records = watchObject.LoadInfo();

            if (!records.Any())
            {
                return(NotFound());
            }

            List <WatchInfoSpeed> list = WatchInfoSpeed.Compile(watchObject, records);
            var results = Fixation.Compile(watchObject, list.ToArray(), this.FixationThreshold);

            var filteredResults = results
                                  .Where(d => d.Duration > 100)
                                  .Where(d => d.Duration < 800)
                                  .Where(d => d.AverageEyeSpeed <= 6)
                                  .Select(d => new
            {
                StartTime = (int)d.StartTime,
                EndTime   = (int)d.EndTime,
                Duration  = (int)d.Duration,
                d.AverageEyeSpeed,
                X = (int)d.X,
                Y = (int)d.Y,
            })
                                  .ToArray();


            using (MemoryStream ms = new MemoryStream())
                using (StreamWriter sw = new StreamWriter(ms))
                    using (CsvWriter writer = new CsvWriter(sw))
                    {
                        writer.WriteRecords(filteredResults);
                        return(Ok(Encoding.UTF8.GetString(ms.ToArray())));
                    }
        }
Ejemplo n.º 3
0
        public IActionResult GetTimePoints(string video, string watch)
        {
            FileInfo f           = new FileInfo(Video.Folder + video + "/" + watch);
            Watch    watchObject = new Watch(f.FullName)
            {
                Video = new Video()
                {
                    Name = video
                }
            };

            var records = watchObject.LoadInfo();

            if (!records.Any())
            {
                return(NotFound());
            }

            List <WatchInfoSpeed> list = WatchInfoSpeed.Compile(watchObject, records);

            return(Ok(list));
        }
Ejemplo n.º 4
0
        public IActionResult GetFixations(string video, string watch)
        {
            FileInfo f           = new FileInfo(Video.Folder + video + "/" + watch);
            Watch    watchObject = new Watch(f.FullName)
            {
                Video = new Video()
                {
                    Name = video
                }
            };

            var records = watchObject.LoadInfo();

            if (!records.Any())
            {
                return(NotFound());
            }

            List <WatchInfoSpeed> list = WatchInfoSpeed.Compile(watchObject, records);
            var results = Fixation.Compile(watchObject, list.ToArray(), this.FixationThreshold);

            var filteredResults = results
                                  .Where(d => d.Duration > 100)
                                  .Where(d => d.Duration < 800)
                                  .Where(d => d.AverageEyeSpeed <= this.FixationThreshold)
                                  .Select(d => new
            {
                StartTime       = (int)d.StartTime,
                EndTime         = (int)d.EndTime,
                Duration        = (int)d.Duration,
                AverageEyeSpeed = Math.Round(d.AverageEyeSpeed, 2, MidpointRounding.ToEven),
                X = (int)d.X,
                Y = (int)d.Y,
            })
                                  .ToArray();

            return(Ok(filteredResults));
        }