| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- using Newtonsoft.Json;
- namespace DaJiaoYan.Models
- {
- public class Rect
- {
- private OpenCvSharp.Rect _rect;
- [JsonProperty(PropertyName = "x", NullValueHandling = NullValueHandling.Ignore)]
- public int X { get; set; }
- [JsonProperty(PropertyName = "y", NullValueHandling = NullValueHandling.Ignore)]
- public int Y { get; set; }
- [JsonProperty(PropertyName = "width", NullValueHandling = NullValueHandling.Ignore)]
- public int Width { get; set; }
- [JsonProperty(PropertyName = "height", NullValueHandling = NullValueHandling.Ignore)]
- public int Height { get; set; }
- /// <summary>
- /// ÇøÓòËùÔÚµÄÖ½ÕÅA/BÃæ
- /// </summary>
- [JsonProperty(PropertyName = "side", NullValueHandling = NullValueHandling.Ignore)]
- public string Side { get; set; }
- [JsonProperty(PropertyName = "uuid", NullValueHandling = NullValueHandling.Ignore)]
- public string UUID { get; set; }
- public Rect(int x, int y, int w, int h)
- {
- X = x; Y = y; Width = w; Height = h;
- }
- public OpenCvSharp.Rect CvRect
- {
- get
- {
- if (_rect == null || _rect.X != X || _rect.Y != Y || _rect.Width != Width || _rect.Height != Height)
- {
- _rect = new OpenCvSharp.Rect
- {
- X = X,
- Y = Y,
- Width = Width,
- Height = Height,
- };
- }
- return _rect;
- }
- }
- public bool Avaliable
- {
- get
- {
- return X >= 0 && Y >= 0 && Width > 0 && Height > 0;
- }
- }
- }
- }
|