Meet YOLO26: next-gen vision AI.

Link to this sectionObject Tracking Heatmaps with Ultralytics YOLO26#

Open Heatmaps In Colab

The Heatmap solution in Ultralytics YOLO26 tracks objects across video frames and overlays their accumulated movement intensity onto each frame, so busy areas glow in warm colors while quiet areas stay cool. Built on YOLO26 object tracking, it turns any video into a spatial activity map that reveals traffic flow, crowd movement, and dwell zones with a single Python call or CLI command.



Watch: Heatmaps using Ultralytics YOLO26

Link to this sectionWhy Use Heatmaps for Video Analytics?#

  • Spot activity patterns at a glance: Intensity accumulates wherever tracked objects spend time, so high-traffic lanes, popular shelves, or crowd bottlenecks stand out without manual frame-by-frame review.
  • Tracking built in: The solution runs YOLO26 detection and tracking internally, so there is no separate tracking pipeline to wire up.
  • Counting in the same pass: Pass a region to count objects entering and exiting a zone while the heatmap builds, combining two analytics tasks in one run.

Link to this sectionReal World Applications#

TransportationRetail
Ultralytics YOLO heatmap overlay showing vehicle traffic densityUltralytics YOLO heatmap overlay showing retail customer movement
Ultralytics YOLO Transportation HeatmapUltralytics YOLO Retail Heatmap

Link to this sectionHow to Generate Heatmaps with Ultralytics YOLO#

Run the Heatmap solution on a video source from the CLI or Python. The Python example writes the processed frames to an output video file:

Heatmaps using Ultralytics YOLO
# Run a heatmap example
yolo solutions heatmap show=True

# Pass a source video
yolo solutions heatmap source="path/to/video.mp4"

# Pass a custom colormap
yolo solutions heatmap colormap=cv2.COLORMAP_INFERNO

# Heatmaps + object counting
yolo solutions heatmap region="[(20, 400), (1080, 400), (1080, 360), (20, 360)]"

Link to this sectionHeatmap() Arguments#

Here's a table with the Heatmap arguments:

ArgumentTypeDefaultDescription
modelstrNonePath to an Ultralytics YOLO model file.
colormapintcv2.COLORMAP_DEEPGREENColormap to use for the heatmap.
show_inboolTrueFlag to control whether to display the in counts on the video stream.
show_outboolTrueFlag to control whether to display the out counts on the video stream.
regionlist or dictNonePoints defining the region of interest, either a list of (x, y) tuples or a dictionary mapping region names to point lists for multiple regions (RegionCounter only). When None, solutions that require a region fall back to a predefined default.

You can also apply different track arguments in the Heatmap solution.

ArgumentTypeDefaultDescription
trackerstr'botsort.yaml'Specifies the tracking algorithm to use. Built-in options: botsort.yaml, bytetrack.yaml, ocsort.yaml, deepocsort.yaml, fasttrack.yaml, tracktrack.yaml.
conffloat0.1Sets the confidence threshold for detections; lower values allow more objects to be tracked but may include false positives.
ioufloat0.7Sets the Intersection over Union (IoU) threshold for filtering overlapping detections.
classeslistNoneFilters results by class index. For example, classes=[0, 2, 3] only tracks the specified classes.
verboseboolTrueControls the display of tracking results, providing a visual output of tracked objects.
devicestrNoneSpecifies the device for inference (e.g., cpu, cuda:0 or 0). Allows users to select between CPU, a specific GPU, or other compute devices for model execution.

Additionally, the supported visualization arguments are listed below:

ArgumentTypeDefaultDescription
showboolFalseIf True, displays the annotated images or videos in a window. Useful for immediate visual feedback during development or testing.
line_widthint or NoneNoneSpecifies the line width of bounding boxes. If None, the line width is automatically adjusted based on the image size. Provides visual customization for clarity.
show_confboolTrueDisplays the confidence score for each detection alongside the label. Gives insight into the model's certainty for each detection.
show_labelsboolTrueDisplays labels for each detection in the visual output. Provides immediate understanding of detected objects.

Link to this sectionHeatmap Colormaps#

The colormap argument accepts any OpenCV colormap. Pass the constant from the cv2 module, for example colormap=cv2.COLORMAP_INFERNO:

Colormap NameDescription
cv2.COLORMAP_AUTUMNAutumn color map
cv2.COLORMAP_BONEBone color map
cv2.COLORMAP_JETJet color map
cv2.COLORMAP_WINTERWinter color map
cv2.COLORMAP_RAINBOWRainbow color map
cv2.COLORMAP_OCEANOcean color map
cv2.COLORMAP_SUMMERSummer color map
cv2.COLORMAP_SPRINGSpring color map
cv2.COLORMAP_COOLCool color map
cv2.COLORMAP_HSVHSV (Hue, Saturation, Value) color map
cv2.COLORMAP_PINKPink color map
cv2.COLORMAP_HOTHot color map
cv2.COLORMAP_PARULAParula color map
cv2.COLORMAP_MAGMAMagma color map
cv2.COLORMAP_INFERNOInferno color map
cv2.COLORMAP_PLASMAPlasma color map
cv2.COLORMAP_VIRIDISViridis color map
cv2.COLORMAP_CIVIDISCividis color map
cv2.COLORMAP_TWILIGHTTwilight color map
cv2.COLORMAP_TWILIGHT_SHIFTEDShifted Twilight color map
cv2.COLORMAP_TURBOTurbo color map
cv2.COLORMAP_DEEPGREENDeep Green color map

Link to this sectionHow Heatmaps Work#

The Heatmap solution extends the ObjectCounter class. On the first processed frame it creates a blank intensity layer matching the frame size. Each frame is then processed in two steps:

  1. YOLO26 tracking detects and follows every object in the frame
  2. For each tracked object, the heatmap intensity increases within a circular region centered in its bounding box

Once per frame, the accumulated intensity layer is normalized, colorized with the selected colormap, and blended with the original frame. The overlay appears as soon as at least one object is tracked; frames without tracked objects are shown without the heatmap overlay.

The result is a dynamic visualization that builds up over time, revealing traffic patterns, crowd movements, or other spatial behaviors in your video data. When a region is set, the solution also counts objects entering and exiting that region while the heatmap builds.

Link to this sectionConclusion#

The Ultralytics YOLO26 Heatmap solution turns object tracking results into an intuitive activity overlay with a few lines of code. To go further, combine it with object counting, explore the other Ultralytics Solutions, or read about the underlying tracking mode.

Link to this sectionFAQ#

Link to this sectionHow does Ultralytics YOLO26 generate heatmaps from a video?#

Ultralytics YOLO26 generates heatmaps by tracking objects across video frames and accumulating an intensity value at each tracked object's location, then colorizing the result and blending it with the original frame. Areas where objects appear frequently or linger build up higher intensity and render in warmer colors. For configuration options, refer to the Heatmap() Arguments section.

Link to this sectionHow do I save the heatmap output to a video file?#

Use OpenCV's cv2.VideoWriter and write results.plot_im for every processed frame, as shown in the main example. The plot_im attribute holds the frame with the heatmap overlay already applied.

Link to this sectionCan I combine heatmaps with object counting?#

Yes. Pass a region argument to Heatmap() with line, rectangle, or polygon points, and the solution counts objects entering and exiting that region while the heatmap builds. The returned results include in_count, out_count, and per-class counts. See the object counting guide for region configuration details.

Link to this sectionHow can I visualize only specific object classes in heatmaps using Ultralytics YOLO26?#

Pass the classes argument to Heatmap() with the class indices you want to keep. For example, classes=[0, 2] builds the heatmap only from persons and cars (COCO class indices 0 and 2):

import cv2

from ultralytics import solutions

cap = cv2.VideoCapture("path/to/video.mp4")
heatmap = solutions.Heatmap(show=True, model="yolo26n.pt", classes=[0, 2])

while cap.isOpened():
    success, im0 = cap.read()
    if not success:
        break
    results = heatmap(im0)
cap.release()
cv2.destroyAllWindows()

Link to this sectionWhat makes Ultralytics YOLO26 heatmaps different from other data visualization tools like those from OpenCV or Matplotlib?#

Ultralytics YOLO26 heatmaps integrate object detection, tracking, intensity accumulation, and overlay rendering into a single call, while generic tools like OpenCV or Matplotlib require you to build that pipeline yourself. The solution processes video streams in real time and supports persistent tracking and customizable colormaps out of the box. For details on the underlying model, see the YOLO26 model page.

Comments