+static Rect getRectInDetection(const Detection& d)
+{
+ Rect r;
+ r.x = d.center_x - d.width / 2;
+ r.y = d.center_y - d.height / 2;
+ r.width = d.width;
+ r.height = d.height;
+ return r;
+}
+
+static double calc_iou_ratio(const Detection& d1, const Detection& d2)
+{
+ Rect r1 = getRectInDetection (d1);
+ Rect r2 = getRectInDetection (d2);
+ Rect r_inner = r1 & r1;
+ Rect r_union = r1 | r2;
+ return 1.0 * r_inner.area() / r_union.area();
+}