Exemple #1
0
        private void LoadBoundingBox(string file)
        {
            _imgAnnotateBoundingBoxList.Clear();
            pbImage.Controls.Clear();
            var width  = _image.Width;
            var height = _image.Height;

            if (!File.Exists(file))
            {
                return;
            }
            var list = IoUtils.File2List(file);

            foreach (var boxInfo in list)
            {
                var arr       = boxInfo.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries);
                var classId   = arr[0].ToInt();
                var centerX   = (arr[1].ToDouble() * width).ToRoundInt();
                var centerY   = (arr[2].ToDouble() * height).ToRoundInt();
                var boxWidth  = (arr[3].ToDouble() * width).ToRoundInt();
                var boxHeight = (arr[4].ToDouble() * height).ToRoundInt();
                var left      = centerX - boxWidth / 2;
                var top       = centerY - boxHeight / 2;
                var dr        = new DragableRectangle()
                {
                    Parent = pbImage, Left = left, Top = top, Width = boxWidth, Height = boxHeight, ClassId = classId
                };
                dr.OnRectDoubleClick += Dr_OnRectDoubleClick;
                _imgAnnotateBoundingBoxList.Add(dr);
            }
        }
Exemple #2
0
        private void Dr_OnRectDoubleClick(DragableRectangle sender)
        {
            var newId = FrmSetBoundingClassId.Execute(sender.ClassId);

            if (newId != -1)
            {
                sender.ClassId = newId;
            }
        }
Exemple #3
0
 private void pbImage_MouseDown(object sender, MouseEventArgs e)
 {
     if (!_imgAnnotateBoundingBoxList.Exists(c => c.Bounds.Contains(e.X, e.Y)))
     {
         _imgAnnotateBoundingBoxList.ForEach(c =>
         {
             c.IsSelected = false;
             c.Invalidate();
         });
     }
     if (_addRegion)
     {
         _newRegionStartPoint = new Point(e.X, e.Y);
         var boxWidth  = 30;
         var boxHeight = 30;
         var dr        = new DragableRectangle()
         {
             Parent = pbImage, Left = _newRegionStartPoint.X - 25, Top = _newRegionStartPoint.Y - 25, Width = boxWidth, Height = boxHeight, ClassId = 0
         };
         dr.OnRectDoubleClick += Dr_OnRectDoubleClick;
         _imgAnnotateBoundingBoxList.Add(dr);
         _addRegion = false;
     }
 }