Example #1
0
        static Dictionary <int, TextLine> nearestLines(double value, int n, PcGts p)
        {
            List <TxtLine>             txtLines      = new List <TxtLine>();
            Dictionary <int, TextLine> neareastLines = new Dictionary <int, TextLine>(); // int is the ID of the textLine

            //compute the distance with every line
            for (int i = 0; i < p.Lines.Count; i++)
            {
                double  linePosY = p.Lines[i].Coords.Rectangle.Y + p.Lines[i].Coords.Rectangle.Height / 2;
                double  dist     = Math.Abs(value - linePosY);
                TxtLine txt      = new TxtLine();
                txt.distance = dist;
                txt.lineID   = i;
                txt.textline = p.Lines[i];
                txtLines.Add(txt);
            }
            //sort distances
            txtLines = txtLines.OrderBy(x => x.distance).ToList();
            //take the n nearest ones
            for (int i = 0; i < n; i++)
            {
                if (i >= txtLines.Count)
                {
                    break;
                }
                neareastLines.Add(txtLines[i].lineID, txtLines[i].textline);
            }
            return(neareastLines);
        }
Example #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Title      = "Please select a PAGE file (xml)";
            ofd.DefaultExt = "xml";
            ofd.Filter     = "xml FIles (*.xml)|*.xml|All (*.*)|*.*";
            ofd.ShowDialog();
            string file = ofd.FileName;

            if (file == null || !File.Exists(file))
            {
                return;
            }
            //deserialize the xml
            page = Retrieval.Program.loadLayout(file);
            labelPageWords.Text = "Page: " + page.Words.Count + " words";
            string imagePath = Path.Combine(Path.GetDirectoryName(file), page.Page.ImageFilename);

            if (File.Exists(imagePath))
            {
                this.pictureBoxTexte.ImageLocation = imagePath;
                this.pictureBoxTexte.Image         = new Bitmap(this.pictureBoxTexte.ImageLocation);
                graphicsText = this.pictureBoxTexte.CreateGraphics();
            }

            else
            {
                Console.WriteLine("The picture is not in the same directory as the xml");
            }
        }
Example #3
0
        public static List <string> findClosestWords(List <Gaze> gd, PcGts layout)
        {
            List <string> words = new List <string>();

            foreach (var item in gd)
            {
                int dist = 0;
                words.Add(closestWord((int)item.gazeX, (int)item.gazeY, layout.Words, out dist));
            }
            return(words);
        }
Example #4
0
        //input a file recorded by tobii
        //outut the tag words as a string. This string can be use in wordle.net
        static void Main(string[] args)
        {
            Console.WriteLine("Write the path to the Tobii file:");
            string tobiiFile = readFile("Timestamp;GazeX;GazeY;LeftEye;RightEye");

            Console.WriteLine("Write the path to the layout file:");
            string   layoutFile = readFile("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
            GazeData gd         = new GazeData(Path.ChangeExtension(tobiiFile, null));
            PcGts    layout     = Retrieval.Program.loadLayout(layoutFile);

            gd.gazes = GazeData.fixationBusher2008(gd.gazes);
            //For each gaze, find the closest word
            List <string> words = findClosestWords(gd, layout);

            //Outpout the words
            foreach (var item in words)
            {
                Console.WriteLine(item);
            }
            Console.WriteLine("Write the path to export the file:");
            string pathSave = Console.ReadLine();

            File.WriteAllLines(pathSave, words);
        }
Example #5
0
 public SpeedEstimator(string pathGaze, PcGts layout)
 {
     this.gd = new GazeData(Path.ChangeExtension(pathGaze, null));
     averageWidthWordSpace = layout.averageWordWidth + layout.averageSpaceLength;
 }