Sunday, February 4, 2018

Intersection over union - Object detection



During object detection ,

When the image has more than one anchor box after filtering by thresholding over the classes scores , we use non-max suppression to get one anchor box for object detection.

Non-max suppression uses intersection over union.

Intersection over union calculates the intersection area of any two boxes by area of union of two boxes.

Here we have considered the  coordinates of each box which are diagonal like top left and bottom right

Our naming conventions here for each box  (x1,y1) – top left and (x2,y2) – bottom right.






Now for two boxes to calculate the intersection need to find the maximum for top left and minimum of bottom right.

X1_inter = max(box1(x1), box2(x1))
Y1_inter = max(box1(y1), box2(y1))
X2_inter = min(box1(x2), box2(x2))
Y2_inter = min(box1(y2), box2(y2))

Here is the code to implement iou:


No comments:

Post a Comment