Compute Intersection over Union for two axis-aligned boxes. Each box is given as [x1,y1,x2,y2], where the first point is the top-left corner and the second is the bottom-right corner.
Aintersection=max(0,xR−xL)max(0,yB−yT) Aunion=AA+AB−Aintersection IoU=AunionAintersectionHere, xL and yT are the largest starting coordinates, while xR and yB are the smallest ending coordinates. Return zero when the union is zero. Otherwise return IoU as a Python float.
Input: box_a = [0, 0, 4, 4], box_b = [2, 2, 6, 6]
Output: 0.142857
Explanation: The intersection area is 4 and the union area is 28.
Input: box_a = [0, 0, 2, 2], box_b = [3, 3, 5, 5]
Output: 0
Use maximum starting coordinates and minimum ending coordinates for the intersection.
Compute union with area_a + area_b - intersection.
Sign in to take notes on this problem
Accepts: array
Accepts: array
Compute Intersection over Union for two axis-aligned boxes. Each box is given as [x1,y1,x2,y2], where the first point is the top-left corner and the second is the bottom-right corner.
Aintersection=max(0,xR−xL)max(0,yB−yT) Aunion=AA+AB−Aintersection IoU=AunionAintersectionHere, xL and yT are the largest starting coordinates, while xR and yB are the smallest ending coordinates. Return zero when the union is zero. Otherwise return IoU as a Python float.
Input: box_a = [0, 0, 4, 4], box_b = [2, 2, 6, 6]
Output: 0.142857
Explanation: The intersection area is 4 and the union area is 28.
Input: box_a = [0, 0, 2, 2], box_b = [3, 3, 5, 5]
Output: 0
Use maximum starting coordinates and minimum ending coordinates for the intersection.
Compute union with area_a + area_b - intersection.
Sign in to take notes on this problem
Accepts: array
Accepts: array