1
0

Rect.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. namespace YOLODetectProcessLib
  5. {
  6. /// <summary>
  7. /// 矩形框,代替System.Drawing.Rectangle
  8. /// </summary>
  9. public struct Rect
  10. {
  11. public int Left { get; set; }
  12. public int Top { get; set; }
  13. public int Right { get; set; }
  14. public int Bottom { get; set; }
  15. public int Width { get; set; }
  16. public int Height { get; set; }
  17. public Rect(int left, int top, int width, int height)
  18. {
  19. if (width < 0)
  20. {
  21. throw new ArgumentException("width", "Width should be greater than 0.");
  22. }
  23. if (height < 0)
  24. {
  25. throw new ArgumentException("height", "Height should be greater than 0");
  26. }
  27. Left = left;
  28. Top = top;
  29. Right = left + width;
  30. Bottom = top + height;
  31. Width = width;
  32. Height = height;
  33. }
  34. public bool IsEmpty()
  35. {
  36. return (Left == 0) && (Right == 0) && (Top == 0) && (Bottom == 0);
  37. }
  38. public static readonly Rect Empty;
  39. }
  40. }