예제 #1
0
        private void ChangeBoxClass(object state)
        {
            var bbox = state as Annotation;

            if (bbox != null && _currentImage != null)
            {
                var sw = new ClassSelectionWindow(_classes.ToList());
                if (sw.ShowDialog() == true)
                {
                    bbox.Label = sw.SelectedClass;
                    bbox.Class = _classes.IndexOf(bbox.Label);
                }
                UpdateBBoxes();
            }
        }
예제 #2
0
 public void UpdateBBoxes()
 {
     _bboxes.Clear();
     if (_currentImage != null)
     {
         var sb        = new StringBuilder();
         var to_remove = new List <Annotation>();
         _bboxes.Add(new Annotation {
             Class = -1, Label = "-- ALL --", Cx = -1, Cy = -1, Width = 0, Height = 0
         });
         foreach (var a in _currentImage.Annotations)
         {
             if (string.IsNullOrWhiteSpace(a.Label))
             {
                 if (!string.IsNullOrWhiteSpace(_defaultClass))
                 {
                     a.Class = _classes.IndexOf(_defaultClass);
                     a.Label = _defaultClass;
                 }
                 else
                 {
                     var sw = new ClassSelectionWindow(_classes.ToList());
                     if (sw.ShowDialog() == true)
                     {
                         a.Label = sw.SelectedClass;
                         a.Class = _classes.IndexOf(a.Label);
                     }
                     else
                     {
                         to_remove.Add(a);
                         continue;
                     }
                 }
             }
             _bboxes.Add(a);
             sb.Append($"{a.Class} {a.Cx.ConvertToString()} {a.Cy.ConvertToString()} {a.Width.ConvertToString()} {a.Height.ConvertToString()}");
             sb.Append("\n");
         }
         foreach (var a in to_remove)
         {
             _currentImage.RemoveAnnotations(a);
         }
         var lp = Path.Combine(Path.GetDirectoryName(_currentImage.FilePath), Path.GetFileNameWithoutExtension(_currentImage.FilePath) + ".txt");
         File.WriteAllText(lp, sb.ToString());
     }
     OnPropertyChanged("BBoxes");
 }