/// <summary> /// Calculate Intersection over Union (IOU) for the given 2 bounding boxes. /// </summary> private static float CalculateIOU(CVBoundingBox box0, CVBoundingBox box1) { var x1 = Math.Max(box0.Left, box1.Left); var y1 = Math.Max(box0.Top, box1.Top); var x2 = Math.Min(box0.Left + box0.Width, box1.Left + box1.Width); var y2 = Math.Min(box0.Top + box0.Height, box1.Top + box1.Height); var w = Math.Max(0, x2 - x1); var h = Math.Max(0, y2 - y1); return(w * h / ((box0.Width * box0.Height) + (box1.Width * box1.Height) - (w * h))); }
public PredictionModel(float probability, string tagName, CVBoundingBox boundingBox) { this.Probability = probability; this.TagName = tagName; this.BoundingBox = boundingBox; }