0
0
Computer Visionml~10 mins

IoU (Intersection over Union) in Computer Vision - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to calculate the area of a bounding box given its coordinates.

Computer Vision
def box_area(x1, y1, x2, y2):
    return (x2 - x1) [1] (y2 - y1)
Drag options to blanks, or click blank then click option'
A*
B-
C+
D/
Attempts:
3 left
💡 Hint
Common Mistakes
Using addition instead of multiplication.
Subtracting the coordinates incorrectly.
2fill in blank
medium

Complete the code to find the coordinates of the intersection box between two bounding boxes.

Computer Vision
def intersection_box(boxA, boxB):
    x_left = max(boxA[0], boxB[0])
    y_top = max(boxA[1], boxB[1])
    x_right = min(boxA[2], boxB[2])
    y_bottom = [1](boxA[3], boxB[3])
    return x_left, y_top, x_right, y_bottom
Drag options to blanks, or click blank then click option'
Amax
Bsum
Cabs
Dmin
Attempts:
3 left
💡 Hint
Common Mistakes
Using max instead of min for bottom coordinate.
Mixing up x and y coordinates.
3fill in blank
hard

Fix the error in the code that calculates the intersection area of two bounding boxes.

Computer Vision
def intersection_area(boxA, boxB):
    x_left, y_top, x_right, y_bottom = intersection_box(boxA, boxB)
    if x_right < x_left or y_bottom < y_top:
        return 0
    return (x_right - x_left) [1] (y_bottom - y_top)
Drag options to blanks, or click blank then click option'
A-
B+
C*
D/
Attempts:
3 left
💡 Hint
Common Mistakes
Using addition instead of multiplication.
Returning negative area values.
4fill in blank
hard

Fill both blanks to compute the union area of two bounding boxes.

Computer Vision
def union_area(boxA, boxB):
    areaA = box_area(*boxA)
    areaB = box_area(*boxB)
    inter_area = intersection_area(boxA, boxB)
    return areaA [1] areaB [2] inter_area
Drag options to blanks, or click blank then click option'
A+
B-
C*
D/
Attempts:
3 left
💡 Hint
Common Mistakes
Adding intersection area instead of subtracting.
Multiplying areas instead of adding.
5fill in blank
hard

Fill all three blanks to complete the IoU calculation function.

Computer Vision
def iou(boxA, boxB):
    inter_area = intersection_area(boxA, boxB)
    union = union_area(boxA, boxB)
    if union == 0:
        return 0
    return [3](inter_area [1] union [2] 1.0)
Drag options to blanks, or click blank then click option'
A/
B*
C==
Dfloat
Attempts:
3 left
💡 Hint
Common Mistakes
Using equality (==) instead of division (/).
Not converting to float causing integer division.