Beispiel #1
0
        // heatmap
        public Image DrawHeatMap(Image img_origin, GazePoint points)
        {
            Image img = (Image)img_origin.Clone();
            Graphics g = Graphics.FromImage(img);

            float step = 30;
            int cell_w = (int)(img.Width / step);
            int cell_h = (int)(img.Height / step);

            int[,] a = new int[cell_h, cell_w];

            foreach (var p in points.list)
            {
                var x = p.X / step;
                var y = p.Y / step;

                if (x > cell_w)
                    x = cell_w - 1;
                if (y > cell_h)
                    y = cell_h - 1;

                a[(int)(y), (int)(x)]++;
            }

            int min = (from int v in a select v).Min();
            int max = (from int v in a select v).Max();
            int mean = (max - min) / 2;

            //draw grid
            for (var i = 0; i < cell_h; i++)
                for (var j = 0; j < cell_w; j++)
                {
                    g.FillRectangle(new SolidBrush(HeatMapColor(a[i, j], min, max)), j * step, i * step, step, step);
                }

            return img;
        }
Beispiel #2
0
        GazePoint loadData()
        {
            //load data left
            openFileDialog.Title = "Data" + spoints.Count.ToString() + 1;

            GazePoint points_tmp = new GazePoint();

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    //load points
                    StreamReader sr = new StreamReader(openFileDialog.FileName);

                    //fill in our gazepoints structure

                    string line = "";

                    string bline = "";
                    int PointCountFromFile = 0;
                    int PointCountCopy = 0;
                    int PointCountClear = 0;

                    while ((line = sr.ReadLine()) != null)
                    {
                        PointCountFromFile++;

                        if (line != bline)
                        {
                            var tmp = line.Split(new string[] { ", " }, StringSplitOptions.None);
                            points_tmp.list.Add(new PointF(float.Parse(tmp[0]), float.Parse(tmp[1])));
                            points_tmp.times.Add(double.Parse(tmp[2]));

                            bline = line;
                            PointCountClear++;
                        }
                        else
                        {
                            PointCountCopy++;
                        }

                    }

                    lInfo.Text = ("Точек в файле: " + PointCountFromFile.ToString() + "\nУдалено дублей: " + PointCountCopy.ToString() + "\nОсталось чистых: " + PointCountClear.ToString());

                    sr.Close();

                }
                catch (Exception ex)
                {

                }
            }

            return points_tmp;
        }
Beispiel #3
0
 public GazePoint(GazePoint inp)
 {
     list = new List<PointF>(inp.list);
     times = new List<double>(inp.times);
 }
Beispiel #4
0
        //open dialogs for all files
        private void left_pic_box_Click(object sender, EventArgs e)
        {
            //load image
            openFileDialog.Title = "Maain Images";
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    filename = openFileDialog.FileName;
                    img_origin = Image.FromFile(openFileDialog.FileName);
                    left_pic_box.Image = img_origin;
                    right_pic_box.Image = img_origin;
                }
                catch (Exception ex)
                {

                }
            }

            //load data left
            openFileDialog.Title = "Data Left";
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    //load points
                    StreamReader sr = new StreamReader(openFileDialog.FileName);

                    //fill in our gazepoints structure
                    points_left = new GazePoint();
                    string line = "";

                    string bline = "";
                    int PointCountFromFile = 0;
                    int PointCountCopy = 0;
                    int PointCountClear = 0;

                    while ((line = sr.ReadLine()) != null)
                    {
                        PointCountFromFile++;

                        if (line != bline)
                        {
                            var tmp = line.Split(new string[] { ", " }, StringSplitOptions.None);
                            points_left.list.Add(new PointF(float.Parse(tmp[0]), float.Parse(tmp[1])));
                            points_left.times.Add(double.Parse(tmp[2]));

                            bline = line;
                            PointCountClear++;
                        }
                        else
                        {
                            PointCountCopy++;
                        }

                    }

                    MessageBox.Show("Точек в файле: " + PointCountFromFile.ToString() + "\nУдалено дублей: " + PointCountCopy.ToString() + "\nОсталось чистых: " + PointCountClear.ToString());

                    sr.Close();
                }
                catch (Exception ex)
                {

                }
            }

            //load data right
            openFileDialog.Title = "Data right";
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    //load points
                    StreamReader sr = new StreamReader(openFileDialog.FileName);

                    //fill in our gazepoints structure
                    points_right = new GazePoint();

                    string line = "";

                    string bline = "";
                    int PointCountFromFile = 0;
                    int PointCountCopy = 0;
                    int PointCountClear = 0;

                    while ((line = sr.ReadLine()) != null)
                    {
                        PointCountFromFile++;

                        if (line != bline)
                        {
                            var tmp = line.Split(new string[] { ", " }, StringSplitOptions.None);
                            points_right.list.Add(new PointF(float.Parse(tmp[0]), float.Parse(tmp[1])));
                            points_right.times.Add(double.Parse(tmp[2]));

                            bline = line;
                            PointCountClear++;
                        }
                        else
                        {
                            PointCountCopy++;
                        }

                    }

                    MessageBox.Show("Точек в файле: " + PointCountFromFile.ToString() + "\nУдалено дублей: " + PointCountCopy.ToString() + "\nОсталось чистых: " + PointCountClear.ToString());

                    sr.Close();
                }
                catch (Exception ex)
                {

                }

            }
        }