12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace YOLODetectProcessLib
- {
- /// <summary>
- /// 矩形框,代替System.Drawing.Rectangle
- /// </summary>
- public struct Rect
- {
- public int Left { get; set; }
- public int Top { get; set; }
- public int Right { get; set; }
- public int Bottom { get; set; }
- public int Width { get; set; }
- public int Height { get; set; }
- public Rect(int left, int top, int width, int height)
- {
- if (width < 0)
- {
- throw new ArgumentException("width", "Width should be greater than 0.");
- }
- if (height < 0)
- {
- throw new ArgumentException("height", "Height should be greater than 0");
- }
- Left = left;
- Top = top;
- Right = left + width;
- Bottom = top + height;
- Width = width;
- Height = height;
- }
- public bool IsEmpty()
- {
- return (Left == 0) && (Right == 0) && (Top == 0) && (Bottom == 0);
- }
- public static readonly Rect Empty;
- }
- }
|