Sub topic 2
Task formulations: single vs multi-person, 2D vs 3D
Pose estimation is not one problem. Before you pick a model, you need to say how many people can appear, which coordinate system the answer uses, and what the input is. This chapter lays out those choices. Later chapters cover the models that solve each case.
This chapter assumes you know the keypoint and skeleton vocabulary from the first chapter, including the COCO 17-keypoint layout. It also assumes basic NumPy and the idea of a bounding box.
Two axes that define the task
Every pose task sits somewhere on two independent axes.
- Number of people: exactly one person, or an unknown number (zero or more).
- Output dimension: 2D positions in image pixels, or 3D positions in a metric space.
A third factor, the input type (a single image or a video), changes what you can do with the output but not the shape of the problem. Temporal smoothing is covered in a later chapter.
| Formulation | Input | Output per image | Typical use |
|---|---|---|---|
| Single-person 2D | Image with one person, often a crop | `(K, 2)` pixels | Fitness apps, cropped datasets |
| Multi-person 2D | Any image | `(N, K, 2)` pixels, N varies | Crowds, sports, surveillance |
| Single-person 3D | Image or video with one person | `(K, 3)` | Animation, biomechanics |
| Multi-person 3D | Any image or multi-camera video | `(N, K, 3)` | Motion capture of groups |
Here K is the number of keypoints (17 for COCO) and N is the number of detected people.
Single-person estimation
In the single-person setting the model is told, or assumes, that the image contains one person who roughly fills the frame. The model only answers "where is each joint?" It never has to decide how many people there are or which joint belongs to whom.
This makes the output a fixed-size array, which suits both direct regression and heatmaps. Many academic benchmarks (such as MPII's single-person track) and the second stage of top-down pipelines use this formulation.
The assumption breaks quickly in practice. If you feed a multi-person photo to a single-person model, it still produces exactly K keypoints. It may place the left shoulder on one person and the right shoulder on another, and no error is raised. The model has no way to say "there are two people here."
Multi-person estimation
In the multi-person setting the model must solve two problems:
- Localization: find every visible joint.
- Association: decide which joints belong to the same person.
The output length N is not known in advance. It can be zero, and your code must handle that case. There are three families of solutions, each covered in its own chapter:
- Top-down: detect people first, then run a single-person estimator on each crop. Association is solved by the detector.
- Bottom-up: detect all joints in the image, then group them into people. Association is solved by a grouping step.
- Single-stage: predict one pose per person directly, with no separate detection or grouping stage.
Coordinate frames in a top-down pipeline
A single-person model inside a top-down pipeline sees a resized crop, not the original image. Its coordinates are in crop pixels. You must map them back to the full image before drawing or evaluating. Forgetting this step is a common bug: the skeleton appears in the top-left corner of the image, scaled wrongly.
import numpy as np
def crop_to_image(coords, box, crop_size):
"""Map (K, 2) x,y coordinates in a resized crop back to full-image pixels.
box: (x0, y0, x1, y1) of the crop in the original image.
crop_size: (width, height) the crop was resized to before the model.
"""
coords = np.asarray(coords, dtype=np.float32)
x0, y0, x1, y1 = box
cw, ch = crop_size
scale = np.array([(x1 - x0) / cw, (y1 - y0) / ch], dtype=np.float32)
return coords * scale + np.array([x0, y0], dtype=np.float32)
# A point at the center of a 192x256 crop taken from box (100, 50, 300, 450)
center = np.array([[96.0, 128.0]])
print(crop_to_image(center, (100, 50, 300, 450), (192, 256)))This prints [[200. 250.]], the center of the box in the original image. Real pipelines often crop with padding to keep the aspect ratio, which adds an offset that you must also undo.
2D estimation
A 2D pose gives each keypoint an (x, y) position in image pixels, usually with a confidence score. It is cheap to compute and easy to annotate, because a person can click on a joint in a photo.
The limits of 2D are structural:
- Units depend on the camera. A 2D elbow angle is measured in the image plane, so it changes when the person turns. A person bending an arm toward the camera can look nearly straight.
- Size depends on distance. A shoulder width of 80 pixels means different things at different distances, so pixel distances cannot be compared across images without normalization.
- No depth ordering. The output does not say which hand is closer to the camera.
For many tasks these limits are acceptable. Counting repetitions, detecting a fall, or driving a screen overlay all work well in 2D.
3D estimation
A 3D pose gives each keypoint (x, y, z) coordinates. The frame you use matters, and results are not comparable between frames:
- Camera-relative: the origin is the camera, and
zis the distance along the optical axis. This needs known camera intrinsics. - Root-relative: the origin is a root joint, usually the pelvis. The pose is about body shape only, with no global position.
- World coordinates: the origin is a fixed point in the scene. This needs camera calibration, or several calibrated cameras.
Many 3D models output root-relative poses because absolute position is hard to recover from one camera. Converting to root-relative form is simple:
import numpy as np
# COCO indices for the left and right hip
L_HIP, R_HIP = 11, 12
def to_root_relative(joints):
"""joints: (K, 3) camera-space coordinates. Returns joints minus the pelvis."""
joints = np.asarray(joints, dtype=np.float64)
pelvis = joints[[L_HIP, R_HIP]].mean(axis=0)
return joints - pelvis
joints = np.zeros((17, 3))
joints[L_HIP] = [0.1, 1.0, 3.0]
joints[R_HIP] = [-0.1, 1.0, 3.0]
joints[0] = [0.0, 0.0, 3.0] # nose, 1 m above the pelvis
print(to_root_relative(joints)[0])This prints [ 0. -1. 0.]. The nose is 1 unit above the pelvis (image y grows downward, so up is negative).
Why 3D from one camera is ambiguous
A single image does not determine depth. Many different 3D poses project to the same 2D pose. A model therefore learns a prior about plausible human bodies, such as fixed bone lengths and joint limits, and uses it to guess. The guess is usually good but can be confidently wrong, especially for unusual poses.
There are two broad ways to produce 3D keypoints:
- Direct: regress 3D coordinates from the image.
- Lifting: run a 2D estimator first, then use a second network to map the 2D skeleton to 3D. The final chapters of this tutorial come back to lifting.
Multi-camera setups remove the ambiguity by triangulation, but they require calibrated cameras and synchronized frames.
Edge cases to plan for
- Zero people. A multi-person model returns an empty list. Code that indexes
[0]without checking will crash. The Ultralytics example in a later chapter guards for this. - Partial bodies. A person cut off by the image border still counts as a person. Their out-of-frame joints are either predicted outside the image or given low confidence.
- Confidence is per keypoint. A person can be detected with high confidence while individual wrists are uncertain. Filter at the keypoint level as well as the person level.
- Dataset format follows the formulation. Single-person datasets give one skeleton per image. COCO gives a list of annotations, one per person, so the same image can hold many.
- Ordering of people is arbitrary. Person 0 in one frame is not necessarily person 0 in the next. Tracking across frames is a separate step.
Choosing a formulation
Start with the simplest one that answers your question.
- If you control the camera and one person is in view, single-person 2D is fast and robust.
- If the scene is uncontrolled, use multi-person 2D. A top-down model is accurate for a few people. A bottom-up or single-stage model keeps cost steady in crowds.
- Move to 3D only when you need depth, real-world units, or angles that do not change with viewpoint.
Exercise
A single-person pose model is run on a photo of two people standing side by side. It returns 17 keypoints with fairly high confidence scores. Name the likely problem and one way to fix it.
Show answer
A single-person model has no way to represent two people, so it mixes joints from both into one skeleton. The fix is to use a multi-person formulation. For example, run a person detector and apply the pose model to each cropped box (top-down), then map each crop's coordinates back to the full image. A bottom-up or single-stage multi-person model also works.
Exercise
A 2D pose gives a right elbow angle of 175 degrees, but the person is clearly bending the arm toward the camera. Why does this happen, and what formulation would help?
Show answer
The 2D angle is measured in the image plane, and a bend along the camera's viewing direction projects to a nearly straight line. A 3D formulation, which estimates depth for each joint, would recover the true angle.