Exemple #1
0
 private void LoadAnnotations()
 {
     if (Directory.Exists(ImageFolder))
     {
         string annXml = Path.Combine(ImageFolder, "Annotations.xml");
         if (File.Exists(annXml))
         {
             _annList = AnnotationList.FromFile(annXml);
         }
         else
         {
             _annList = new AnnotationList();
         }
         if (_files != null)
         {
             foreach (string file in _files)
             {
                 if (!_annList.ContainsKey(file))
                 {
                     _annList.Add(file);
                 }
             }
         }
     }
 }
Exemple #2
0
 private void SaveAnnotations(string fileName)
 {
     SaveImageRectangles(CurrenIndex);
     if (Directory.Exists(ImageFolder))
     {
         if (_annList == null)
         {
             _annList = new AnnotationList();
         }
         _annList.Save(fileName);
     }
 }
Exemple #3
0
        public static AnnotationList FromFile(string fileName)
        {
            TextReader    tr = new StreamReader(fileName);
            XmlSerializer xs = new XmlSerializer(typeof(AnnotationEntry[]), new XmlRootAttribute()
            {
                ElementName = "Entries"
            });

            AnnotationEntry[] aentry = (AnnotationEntry[])xs.Deserialize(tr);
            tr.Close();

            AnnotationList result = new AnnotationList();

            foreach (AnnotationEntry en in aentry)
            {
                result.Add(en.File, en.Rectangles);
            }

            return(result);
        }