Пример #1
0
        public override IEnumerable<IO.VolkeTest.VolkeEyeSensorMessage> ApplyFilter(IEnumerable<IO.VolkeTest.VolkeEyeSensorMessage> eyeMovements)
        {
            LookPoint.Filters.WeightOOTriangular filterR = new LookPoint.Filters.WeightOOTriangular();
            LookPoint.Filters.WeightOOTriangular filterL = new LookPoint.Filters.WeightOOTriangular();

            var buffer = new Queue<BufferPoint>();
            BufferPoint lastPoint = BufferPoint.Empty;
            foreach (var eyeTracking in eyeMovements)
            {
                var point = new BufferPoint(eyeTracking.LeftPosition, eyeTracking.RightPosition, (int)eyeTracking.Timestamp);

                //if (point.HasEmpty())
                //{
                //    buffer.Enqueue(point);
                //    continue;
                //}

                if (buffer.Count > 0)
                {
                    int intervalSize = buffer.Count;
                    var start = lastPoint == BufferPoint.Empty ? point : lastPoint;
                    var next = lastPoint == BufferPoint.Empty ? point : lastPoint;

                    int idx = 0;
                    while (buffer.Count > 0)
                    {
                        var midPoint = buffer.Dequeue();
                        Correct(midPoint, start, next, intervalSize, ++idx);
                        yield return point.ToSensorMessage(filterL, filterR);
                    }
                }

                yield return point.ToSensorMessage(filterL, filterR);
                lastPoint = point;
            }
        }
Пример #2
0
        public IEnumerable<EyeTrackingInfo> GetFilteredPoints()
        {
            LookPoint.Filters.WeightOOTriangular filter = new LookPoint.Filters.WeightOOTriangular();
            int filterCount = 0;

            foreach (var eyeTracking in this.EyeTrackingInfo)
            {
                var x = (eyeTracking.LeftEye.X + eyeTracking.RightEye.X) / 2;
                var y = (eyeTracking.LeftEye.Y + eyeTracking.RightEye.Y) / 2;
                var fp = filter.feed(++filterCount * 20, new PointF((float)x, (float)y));
                var point = new Point((int)fp.X, (int)fp.Y);
                yield return new EyeTrackingInfo(point, point, eyeTracking.Timestamp);
            }
        }
Пример #3
0
        public void GenerateHeatMap(string subject)
        {
            var path = "maps\\" + subject.Replace(".volke", "");
            if (!Directory.Exists("maps")) Directory.CreateDirectory("maps");
            if (!Directory.Exists(path)) Directory.CreateDirectory(path);

            int maskSize = 150;
            var mask = GetMask(maskSize);
            int[,] exposure = new int[850, 850];

            LookPoint.Filters.WeightOOTriangular filter = new LookPoint.Filters.WeightOOTriangular();
            int filterCount = 0;

            foreach (var eyeTracking in this.GetFixations().SelectMany(i => i))
            {
                var mx = (eyeTracking.LeftEye.X + eyeTracking.RightEye.X) / 2;
                var my = (eyeTracking.LeftEye.Y + eyeTracking.RightEye.Y) / 2;
                var fp = filter.feed(++filterCount * 20, new PointF((float)mx, (float)my));
                var point = new Point((int)fp.X, (int)fp.Y);

                if (point.X < 0 || point.Y < 0 || point.X >= 850 || point.Y >= 850)
                    continue;

                int exposureValue = 10;
                for (int x = 0; x < maskSize; x++)
                {
                    int targetX = point.X - (maskSize / 2) + x;
                    if (targetX < 0 || targetX >= 850) continue;

                    for (int y = 0; y < maskSize; y++)
                    {
                        int targetY = point.Y - (maskSize / 2) + y;
                        if (targetY < 0 || targetY >= 850 || mask[x, y] == 0) continue;

                        exposure[targetX, targetY] += exposureValue * mask[x, y];
                    }
                }
            }

            float max = exposure.Cast<int>().Max();

            for (int x = 0; x < 850; x++)
                for (int y = 0; y < 850; y++)
                    this.BoardImage.SetPixel(x, y, GetColor(this.BoardImage.GetPixel(x, y), exposure[x, y], max));

            var bmp = new Bitmap(850, 900);

            using (var g = bmp.GetGraphics())
            {
                g.Graphics.DrawString(this.Test.Question, new Font("Calibri", 12), Brushes.Black, 5, 5);
                g.Graphics.DrawString(this.Test.IsCorrect ? "SIM" : "NÃO", new Font("Calibri", 12, FontStyle.Bold), Brushes.Black, 5, 22);
                g.Graphics.DrawImageUnscaled(this.BoardImage, 0, 80);
            }

            bmp.Save(path + "\\" + this.Test.Id + ".png");
        }