예제 #1
0
        public static string processOneFile(string filenameWithoutExtention)
        {
            Console.WriteLine("Processing the file: " + filenameWithoutExtention);
            GazeData gd = new GazeData(filenameWithoutExtention);

            //writeImage(gd, gd.pngOriginal); //Display the raw gazes in a picture
            //writeVideo(gd, gd.aviOriginal); //Create a video of the gazes

            //Compute the fixations
            gd.gazes = GazeData.fixationBusher2008(gd.gazes);
            writeText(gd, gd.csvFixations);         //save the fixations in a file
            writeImage(gd, gd.pngFixations, false); //Display the fixations in a picture
                                                    //writeVideo(gd, gd.aviFixations);

            ////Line break detection
            ////gd.rowDataLineBreak(-40, 3, 2); //not usually used
            //gd.lines = GazeData.lineBreakDetectionSimple(ref gd.gazes, -500);
            ////gd.lineBreakDetectionOkoso(); //not usually used
            //writeText(gd, gd.csvFixations); //save the fixations in a file
            //writeImage(gd, gd.pngLineBreak, false);
            ////writeVideo(gd, gd.aviLineBreak);

            //Align gaze with lines
            //align(gd, "doc.layout");
            //writeImage(gd, gd.pngFixations);
            //writeVideo(gd, gd.aviFixations);

            return(gd.csvFixations);
        }
예제 #2
0
        public static void writeImage(GazeData gd, string outputFile, string backGroundImage)
        {
            // quick hack because some people though it was a good idea to put tobii on a second screen but we have no idea what is the size of the first screen!!!

            Bitmap     image = new Bitmap(backGroundImage);
            Graphics   g     = Graphics.FromImage(image);
            SolidBrush brush = new SolidBrush(Color.Red);

            for (int i = 0; i < gd.gazes.Count; i++)
            {
                g.FillEllipse(brush, new Rectangle((int)gd.gazes[i].gazeX - 5, (int)gd.gazes[i].gazeY - 5, 10, 10));
            }
            g.Save();
            image.Save(outputFile);
            Console.WriteLine("The image " + outputFile + " file has been written");
        }
예제 #3
0
 public static void writeImage(GazeData gd, string outputFile, bool useBackGround)
 {
     if (gd.width > 0 && gd.height > 0)
     {
         // quick hack because some people though it was a good idea to put tobii on a second screen but we have no idea what is the size of the first screen!!!
         if (gd.gazes[gd.gazes.Count - 1].gazeX > gd.width)
         {
             gd.width += Screen.PrimaryScreen.Bounds.Width;
             if (Screen.PrimaryScreen.Bounds.Height > gd.height)
             {
                 gd.height = Screen.PrimaryScreen.Bounds.Height;
             }
         }
         Bitmap   image = new Bitmap(gd.width, gd.height);
         Graphics g     = Graphics.FromImage(image);
         g.Clear(Color.White);
         SolidBrush brush = new SolidBrush(Color.Red);
         //Put the background
         if (gd.backgroundPath != "" && useBackGround)
         {
             Image back = Image.FromFile(gd.backgroundPath);
             g.DrawImage(back, (gd.width - back.Width) / 2, (gd.height - back.Height) / 2);
         }
         for (int i = 0; i < gd.gazes.Count; i++)
         {
             //Use different color for different lines
             if (gd.gazes[i].idLine == 0)
             {
                 brush.Color = Color.Black;
             }
             else
             {
                 brush.Color = colors[gd.gazes[i].idLine % colors.Count];
             }
             g.FillEllipse(brush, new Rectangle((int)gd.gazes[i].gazeX - 5, (int)gd.gazes[i].gazeY - 5, 10, 10));
         }
         g.Save();
         image.Save(outputFile);
         Console.WriteLine("The image " + outputFile + " file has been written");
     }
     else
     {
         Console.WriteLine("The image cannot be written");
     }
 }
예제 #4
0
        public static void writeText(GazeData gd, string outputFile)
        {
            System.Globalization.CultureInfo customCulture = (System.Globalization.CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone();
            customCulture.NumberFormat.NumberDecimalSeparator    = ".";
            System.Threading.Thread.CurrentThread.CurrentCulture = customCulture;

            List <string> textLines = new List <string>();

            //header
            textLines.Add("timestamp;gazeX;gazeY;duration;idLine");
            //content
            foreach (var gaze in gd.gazes)
            {
                textLines.Add(gaze.timestamp + ";" + gaze.gazeX + ";" + gaze.gazeY + ";" + gaze.duration + ";" + gaze.idLine);
            }

            File.WriteAllLines(outputFile, textLines.ToArray());
        }
예제 #5
0
        public static void writeVideo(GazeData gd, string path)
        {
            Bitmap     image = new Bitmap(gd.width, gd.height);
            Graphics   g     = Graphics.FromImage(image);
            SolidBrush brush = new SolidBrush(Color.Red);
            //Display the gaze in one video
            VideoFileWriter writer = new VideoFileWriter();

            writer.Open(path, gd.width, gd.height);
            //Bitmap image = new Bitmap(width, height);
            //Graphics g = Graphics.FromImage(image);
            //Brush brush = Brushes.Red;
            g.Clear(Color.Black);
            //Put the background
            if (gd.backgroundPath != "")
            {
                Image back = Image.FromFile(gd.backgroundPath);
                g.DrawImage(back, (gd.width - back.Width) / 2, (gd.height - back.Height) / 2);
            }
            Console.WriteLine("Writing the video, it can take some times...");
            // write the frames
            for (int i = 0; i < gd.gazes.Count; i++)
            {
                //Use different color for different lines
                if (gd.gazes[i].idLine == 0)
                {
                    brush.Color = Color.Black;
                }
                else
                {
                    brush.Color = colors[gd.gazes[i].idLine % colors.Count];
                }
                g.FillEllipse(brush, new Rectangle((int)gd.gazes[i].gazeX - 5, (int)gd.gazes[i].gazeY - 5, 10, 10));
                g.Save();
                writer.WriteVideoFrame(image, new TimeSpan(0, 0, 0, 0, (int)gd.gazes[i].timestamp));
            }
            writer.Close();
        }