Diff of /utils.py [000000] .. [d34869]

Switch to side-by-side view

--- a
+++ b/utils.py
@@ -0,0 +1,15 @@
+def iou(boxA, boxB):
+    xA = max(boxA[0], boxB[0])
+    yA = max(boxA[1], boxB[1])
+    xB = min(boxA[2], boxB[2])
+    yB = min(boxA[3], boxB[3])
+
+    interArea = (xB - xA + 1) * (yB - yA + 1)
+
+    if interArea < 0:
+        interArea = 0
+
+    boxAArea = (boxA[2] - boxA[0] + 1) * (boxA[3] - boxA[1] + 1)
+    boxBArea = (boxB[2] - boxB[0] + 1) * (boxB[3] - boxB[1] + 1)
+
+    return interArea / float(boxAArea + boxBArea - interArea)