License YOLO
Back to Ultralytics Glossary

Bounding Box

A bounding box is the rectangle that marks where an object sits in an image. Covers xyxy, xywh and YOLO formats, labeling, and rotated and 3D boxes.

A bounding box is the smallest axis-aligned rectangle that encloses an object in an image or video frame, described by four numbers. It is the unit of output in object detection: a detector returns one box per object together with a class label and a confidence score, and annotators draw the same boxes on training data to teach the model. A box locates an object and gives its rough size without tracing its shape, which makes boxes quick to label and cheap to predict.

Coordinate Formats#

Image coordinates start at the top-left corner, with x growing to the right and y growing downward. Every box format stores four numbers, but datasets and libraries disagree on which four, and mixing them up silently shifts or stretches every box.

  • Corners (xyxy): the top-left corner (x1, y1) and the bottom-right corner (x2, y2), in pixels. PASCAL VOC annotations and most drawing and IoU functions use this form.
  • COCO format: the top-left corner followed by the width and height, [x, y, width, height], in pixels.
  • YOLO format: the box center followed by its width and height, each divided by the image width or height so every value falls between 0 and 1. Ultralytics YOLO models such as YOLO26 train from one text file per image with one row per object: the class index, then x_center, y_center, width, and height.

Normalized coordinates survive resizing: an image can be scaled to any training resolution without rewriting its labels, because the boxes are stored as fractions of the image size.

from ultralytics import YOLO

# Load a pretrained YOLO26 nano detector
model = YOLO("yolo26n.pt")

# Detect objects and take the boxes from the first image
results = model("https://ultralytics.com/images/bus.jpg")
boxes = results[0].boxes

# The same first box in four formats
print(boxes.xyxy[0])  # corners in pixels
print(boxes.xywh[0])  # center, width, height in pixels
print(boxes.xyxyn[0])  # corners divided by image width and height
print(boxes.xywhn[0])  # center and size divided by image size, as in YOLO labels

All four lines describe one rectangle. The normalized versions divide the pixel values by the 810 × 1080 size of the image, and xywh is measured from the box center, so it differs from COCO's top-left xywh.

How Detectors Predict Boxes#

A detector predicts boxes as regression outputs at many positions in the image. Earlier designs predicted offsets from predefined anchor boxes of fixed sizes and aspect ratios, and anchor-free detectors predict the distances from a grid point to the four box edges directly. Training compares predicted and labeled boxes with losses based on intersection over union (IoU), and because neighboring positions predict overlapping boxes for the same object, non-maximum suppression (NMS) removes the duplicates at inference.

Labeling Bounding Boxes#

A detector learns to draw boxes the way its labels are drawn, so data annotation guidelines decide box quality. Good guidelines ask for boxes that touch the visible edges of each object, for every instance of every class to be labeled, since an unlabeled object teaches the model that it is background, and for a fixed rule on occluded and truncated objects, such as boxing only the visible part. Evaluation inherits the same rules, because a prediction is scored by its IoU with the labeled box.

Bounding Boxes vs. Other Region Types#

  • Oriented bounding boxes (OBB): a fifth value, the rotation angle, lets the box turn to fit angled objects such as ships or vehicles in aerial images with much less background inside.
  • Instance segmentation: a per-pixel mask that outlines each object's exact shape.
  • Keypoints: individual landmark points, such as body joints for pose estimation.
  • 3D bounding boxes: cuboids in real-world space, usually described by seven numbers: the center (x, y, z), the length, width, and height in meters, and a heading angle.

Explore solutions

Computer vision in sports

Computer vision in sports

Discover how Ultralytics YOLO powers sports vision with player and ball tracking, performance analytics, coaching insights, and athlete rehabilitation.
Learn more
Computer vision for aerial imagery

Computer vision for aerial imagery

Turn drone and aerial imagery into real-time insights for agriculture, aquaculture, conservation, and geospatial analysis with Ultralytics YOLO.
Learn more
Computer vision in aerospace

Computer vision in aerospace

Apply computer vision in aerospace with Ultralytics YOLO for aircraft inspection, runway FOD detection, airport ground operations, and composite defect detection.
Learn more
Computer vision in security

Computer vision in security

Protect every site with Ultralytics YOLO models. Vision AI powers perimeter monitoring, threat detection, license-plate recognition, and workplace safety.
Learn more
Computer vision in robotics

Computer vision in robotics

Power smarter machines with Ultralytics YOLO models. Vision AI in robotics drives autonomous navigation, perception, object tracking, and real-time control.
Learn more
Computer vision in logistics

Computer vision in logistics

Streamline logistics with Ultralytics YOLO models. Vision AI enables package inspection, sorting, vehicle tracking, and real-time warehouse safety monitoring.
Learn more
Computer vision in retail

Computer vision in retail

Reimagine retail with Ultralytics YOLO models. Vision AI powers inventory tracking, shelf monitoring, queue management, and smarter customer insights.
Learn more
Computer vision in healthcare

Computer vision in healthcare

Build healthcare solutions with Ultralytics YOLO models. Vision AI in healthcare powers faster medical imaging, smarter diagnostics, and patient monitoring.
Learn more
Computer vision in manufacturing

Computer vision in manufacturing

Optimize manufacturing with Ultralytics YOLO models. Vision AI drives quality control, defect detection, PPE compliance, and assembly line automation.
Learn more
Computer vision in automotive

Computer vision in automotive

Apply computer vision in automotive with Ultralytics YOLO models. Vision AI elevates road safety, driver assistance, and vehicle automation for smarter roads.
Learn more
Computer vision in agriculture

Computer vision in agriculture

Bring vision AI to smart agriculture with Ultralytics YOLO models. Power crop monitoring, livestock tracking, and precision farming for higher, smarter yields.
Learn more

Let's build the future of AI together!

Begin your journey with the future of machine learning