In object detection, bounding boxes show where objects are in images. The key metric is Intersection over Union (IoU). It measures how much the predicted box overlaps the true box. A higher IoU means better prediction. IoU helps us know if the box is placed well and sized correctly.
Bounding box representation in Computer Vision - Model Metrics & Evaluation
Bounding box evaluation uses IoU threshold to decide if a prediction is correct (True Positive) or wrong (False Positive). For example:
Ground Truth Box: [x1=30, y1=40, x2=70, y2=80]
Predicted Box: [x1=35, y1=45, x2=75, y2=85]
IoU = Area of Overlap / Area of Union
If IoU >= 0.5, count as True Positive (TP)
Else, count as False Positive (FP)
Confusion counts:
TP = 1
FP = 0
FN = 0 (missed boxes)
TN = Not used in bounding box detection
Precision means how many predicted boxes are correct. High precision means few false boxes.
Recall means how many true boxes are found. High recall means few missed objects.
Example:
- If you want to avoid false alarms (like detecting a cat where there is none), focus on high precision.
- If you want to find all objects (like spotting every car in traffic), focus on high recall.
Usually, increasing recall lowers precision and vice versa. IoU threshold tuning affects this tradeoff.
Good: IoU >= 0.7 means boxes overlap well. Precision and recall above 0.8 show reliable detection.
Bad: IoU < 0.5 means poor overlap. Precision or recall below 0.5 means many wrong or missed boxes.
Example: IoU = 0.3 means predicted box barely covers the object, so detection is poor.
- Ignoring IoU threshold: Counting all predicted boxes as correct without overlap check leads to falsely high accuracy.
- Data leakage: Testing on images seen during training inflates metrics.
- Overfitting: Model predicts training boxes perfectly but fails on new images, causing low recall.
- Confusing precision and recall: High precision but low recall means many objects missed.
Your model has 98% accuracy but average IoU of 0.4 and recall of 30%. Is it good?
Answer: No. High accuracy here is misleading because accuracy does not reflect bounding box quality. IoU of 0.4 is low, meaning boxes poorly overlap objects. Recall of 30% means many objects are missed. The model needs improvement to detect objects correctly and completely.
Practice
Solution
Step 1: Understand bounding box purpose
A bounding box is used to locate objects visually in an image.Step 2: Identify bounding box representation
It uses four numbers to mark the top-left and bottom-right corners of the object.Final Answer:
The location of an object in an image using four numbers -> Option AQuick Check:
Bounding box = object location [OK]
- Confusing bounding box with color or texture
- Thinking bounding box covers the whole image
- Believing bounding box uses only two numbers
Solution
Step 1: Recall bounding box corner points
The bounding box is defined by the top-left and bottom-right corners.Step 2: Match the correct order
The order is (top-left x, top-left y, bottom-right x, bottom-right y).Final Answer:
(top-left x, top-left y, bottom-right x, bottom-right y) -> Option DQuick Check:
Bounding box corners = top-left and bottom-right [OK]
- Mixing center coordinates with corner points
- Swapping bottom-left with top-left
- Using width and height before coordinates
Solution
Step 1: Calculate width from x-coordinates
Width = bottom-right x - top-left x = 50 - 10 = 40.Step 2: Calculate height from y-coordinates
Height = bottom-right y - top-left y = 80 - 20 = 60.Final Answer:
Width = 40, Height = 60 -> Option AQuick Check:
Width = 50-10, Height = 80-20 [OK]
- Swapping width and height values
- Adding coordinates instead of subtracting
- Using top-left y for width calculation
bbox = (x1=30, y1=40, x2=20, y2=70)Solution
Step 1: Check coordinate order validity
Bounding box requires bottom-right x (x2) to be greater than top-left x (x1).Step 2: Identify the error
Here, x2=20 is less than x1=30, which is invalid and would cause errors in drawing or calculations.Final Answer:
x2 is less than x1, which is invalid for bounding boxes -> Option BQuick Check:
x2 must be > x1 for valid box [OK]
- Ignoring coordinate order rules
- Thinking y2 must be less than y1
- Assuming bounding box needs 5 values
Solution
Step 1: Understand center to corner conversion
Center coordinates are in the middle of the box; to get corners, subtract half width/height for top-left.Step 2: Calculate corners from center and size
Top-left x = center_x - width/2; top-left y = center_y - height/2; bottom-right x = center_x + width/2; bottom-right y = center_y + height/2.Final Answer:
top-left x = center_x - width/2; top-left y = center_y - height/2; bottom-right x = center_x + width/2; bottom-right y = center_y + height/2 -> Option CQuick Check:
Center ± half size = corners [OK]
- Adding half width to top-left instead of subtracting
- Swapping top-left and bottom-right calculations
- Using width and height as coordinates directly
Ready to prove it?
Pass the test and this pattern moves unknown
