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; } /// /// 区域所在的纸张A/B面 /// [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; } } } }