Complete the code to create a bounding box represented by its top-left corner and width and height.
bbox = {'x': 50, 'y': 100, 'width': 200, 'height': [1]The height of the bounding box is 150 pixels, so we fill in the height value as 150.
Complete the code to calculate the bottom-right corner coordinates of the bounding box.
bottom_right_x = bbox['x'] + [1] bottom_right_y = bbox['y'] + bbox['height']
The bottom-right x coordinate is the top-left x plus the width of the bounding box.
Fix the error in the code to correctly compute the bounding box area.
area = bbox['width'] [1] bbox['height']
The area of a rectangle is width multiplied by height.
Fill both blanks to create a dictionary comprehension that maps each bounding box id to its area.
areas = {box_id: bbox[1] bbox[2] for box_id, bbox in boxes.items()}We multiply the width and height values from each bounding box to get the area.
Fill all three blanks to create a function that converts bounding box from (x, y, width, height) to (x_min, y_min, x_max, y_max).
def convert_bbox(bbox): x_min = bbox['x'] y_min = bbox['y'] x_max = bbox['x'] [1] bbox['width'] y_max = bbox['y'] [2] bbox[[3]] return (x_min, y_min, x_max, y_max)
To get x_max and y_max, add width to x and height to y respectively.