Sub topic 1
What a Pose Is: Keypoints, Skeletons and the COCO Layout
Prerequisites
This chapter assumes you know basic Python and NumPy, have seen convolutional neural networks used for image classification, and understand the idea of a bounding box from object detection.
Keypoints and skeletons
A keypoint is a named point on a body, such as the left elbow or the right ankle. A skeleton is a set of edges that connects keypoints in anatomical order, for example shoulder to elbow to wrist. Together, the keypoints and their skeleton describe a pose.
The COCO keypoint layout defines 17 keypoints per person: nose, left and right eye, left and right ear, left and right shoulder, elbow, wrist, hip, knee and ankle. Each keypoint has an (x, y) position in pixels and a visibility flag.
Task formulations
Single-person pose estimation assumes one person per image. Multi-person pose estimation handles any number of people and must also decide which keypoints belong to which person.
Most current work is 2D: it predicts pixel coordinates in the image. 3D pose estimation predicts coordinates in space, usually with a depth value added to each keypoint.
Datasets, annotations and visibility flags
COCO-style annotations store each person as a record with a bounding box, a keypoint list of 17 triples (x, y, v), and a visibility flag v:
v = 0: not labelled, so the point is absent from the image.v = 1: labelled but occluded.v = 2: labelled and visible.
Training and evaluation must respect these flags. A model should not be penalised for missing a point that is marked v = 0.
Direct coordinate regression and its limits
The simplest model outputs 34 numbers, the x and y of each keypoint, from a global feature vector. Training minimises the distance between predicted and labelled coordinates.
This approach is easy to build but weak in practice. The mapping from image features to exact pixel positions is highly nonlinear, and the model often averages over spatial detail. Errors grow for unusual poses and small images.
Heatmaps: representing each keypoint as a spatial map
A heatmap model outputs one map per keypoint, each with the same height and width as the feature grid. The target map for a keypoint is a 2D Gaussian centred on its true location, so nearby pixels get partial credit. The value at each pixel is the model's belief that the keypoint is there.
Heatmaps keep spatial information that regression discards. They are the basis of most modern pose models, and decoding them into coordinates is covered in the next chapter.
import numpy as np
def gaussian_heatmap(h, w, cx, cy, sigma=2.0):
ys, xs = np.mgrid[0:h, 0:w]
return np.exp(-((xs - cx) ** 2 + (ys - cy) ** 2) / (2 * sigma ** 2))
hm = gaussian_heatmap(64, 48, cx=20, cy=30)
print(hm.shape, hm.max(), np.unravel_index(hm.argmax(), hm.shape))Exercise
Exercise
The COCO layout has 17 keypoints. Why does a heatmap model output 17 maps rather than one map with 17 peaks?
Show answer
Each keypoint needs its own map so that each map's peak marks one keypoint's location. A single map would not separate keypoints that overlap in space or belong to different body parts.