Meet YOLO26: next-gen vision AI.

Link to this sectionTrackZone using Ultralytics YOLO26#

Link to this sectionWhat is TrackZone?#

Open TrackZone In Colab

TrackZone specializes in monitoring objects within designated areas of a frame instead of the whole frame. Built on Ultralytics YOLO26, it integrates object detection and tracking specifically within zones for videos and live camera feeds. YOLO26's advanced algorithms and deep learning technologies make it a perfect choice for real-time use cases, offering precise and efficient object tracking in applications like crowd monitoring and surveillance.



Watch: How to Track Objects in Region using Ultralytics YOLO26 | TrackZone 🚀

Link to this sectionAdvantages of Object Tracking in Zones (TrackZone)#

  • Targeted Analysis: Tracking objects within specific zones allows for more focused insights, enabling precise monitoring and analysis of areas of interest, such as entry points or restricted zones.
  • Reduced Downstream Workload: By ignoring objects outside the zone, TrackZone removes irrelevant detections so there are fewer objects to count, log, or alert on in the logic you build on top of it. Detection still runs on a full-size masked frame rather than a tight crop of the zone, so the benefit is cleaner, more focused output rather than faster model inference.
  • Enhanced Security: Zonal tracking improves surveillance by monitoring critical areas, aiding in the early detection of unusual activity or security breaches.
  • Scalable Solutions: The ability to focus on specific zones makes TrackZone adaptable to various scenarios, from retail spaces to industrial settings, ensuring seamless integration and scalability.

Link to this sectionReal World Applications#

AgricultureTransportation
Plants Tracking in Field Using Ultralytics YOLO26Vehicles Tracking on Road using Ultralytics YOLO26
Plants Tracking in Field Using Ultralytics YOLO26Vehicles Tracking on Road using Ultralytics YOLO26
TrackZone using Ultralytics YOLO
# Run a trackzone example
yolo solutions trackzone show=True

# Pass a source video
yolo solutions trackzone source="path/to/video.mp4" show=True

# Pass region coordinates
yolo solutions trackzone show=True region="[(150, 150), (1130, 150), (1130, 570), (150, 570)]"

TrackZone relies on the region list to know which part of the frame to monitor. Define the polygon to match the physical zone you care about (doors, gates, etc.), and keep show=True enabled while configuring so you can verify the overlay aligns with the video feed.

Defining the tracking zone
  • Each entry in region is an (x, y) pixel coordinate in the video frame. List the points in the order they should be connected around the perimeter of the area you want to monitor.
  • Coordinates are tied to the frame resolution, so a region sized for a 1280×720 feed will not line up with a 640×480 one. Keep show=True while configuring so you can confirm the overlay matches your feed.
  • TrackZone reduces the points to their convex hull, so a concave shape is simplified to the smallest convex polygon that contains all of its points. For non-convex shapes or several separate areas, use the RegionCounter solution instead.
  • If you omit region entirely, a default zone of [(75, 75), (565, 75), (565, 285), (75, 285)] is used.

Link to this sectionTrackZone Arguments#

Here's a table with the TrackZone arguments:

ArgumentTypeDefaultDescription
modelstrNonePath to an Ultralytics YOLO model file.
regionlist'[(20, 400), (1260, 400)]'List of points defining the counting region.

The TrackZone solution includes support for track parameters:

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.

Moreover, the following visualization options are available:

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 sectionCount Objects Inside the Zone#

Every call to the tracker returns a SolutionResults object whose total_tracks attribute holds the number of objects currently tracked inside the zone. Read it on each frame to monitor live occupancy, for example to log how busy an entry point or restricted area is:

import cv2

from ultralytics import solutions

cap = cv2.VideoCapture("path/to/video.mp4")
assert cap.isOpened(), "Error reading video file"

region_points = [(150, 150), (1130, 150), (1130, 570), (150, 570)]
trackzone = solutions.TrackZone(show=False, region=region_points, model="yolo26n.pt")

while cap.isOpened():
    success, im0 = cap.read()
    if not success:
        break
    results = trackzone(im0)
    print(f"Objects currently in zone: {results.total_tracks}")  # live zone occupancy

cap.release()

Link to this sectionFAQ#

Link to this sectionHow do I track objects in a specific area or zone of a video frame using Ultralytics YOLO26?#

Tracking objects in a defined area or zone of a video frame is straightforward with Ultralytics YOLO26. Simply use the command provided below to initiate tracking. This approach ensures efficient analysis and accurate results, making it ideal for applications like surveillance, crowd management, or any scenario requiring zonal tracking.

yolo solutions trackzone source="path/to/video.mp4" show=True

Link to this sectionHow can I use TrackZone in Python with Ultralytics YOLO26?#

With just a few lines of code, you can set up object tracking in specific zones, making it easy to integrate into your projects.

import cv2

from ultralytics import solutions

cap = cv2.VideoCapture("path/to/video.mp4")
assert cap.isOpened(), "Error reading video file"
w, h, fps = (int(cap.get(x)) for x in (cv2.CAP_PROP_FRAME_WIDTH, cv2.CAP_PROP_FRAME_HEIGHT, cv2.CAP_PROP_FPS))
video_writer = cv2.VideoWriter("trackzone_output.avi", cv2.VideoWriter_fourcc(*"mp4v"), fps, (w, h))

trackzone = solutions.TrackZone(
    show=True, region=[(150, 150), (1130, 150), (1130, 570), (150, 570)], model="yolo26n.pt"
)

while cap.isOpened():
    success, im0 = cap.read()
    if not success:
        break
    results = trackzone(im0)
    video_writer.write(results.plot_im)

cap.release()
video_writer.release()
cv2.destroyAllWindows()

Link to this sectionHow do I configure the zone points for video processing using Ultralytics TrackZone?#

Configuring zone points for video processing with Ultralytics TrackZone is simple and customizable. You can directly define and adjust the zones through a Python script, allowing precise control over the areas you want to monitor.

# Define region points
region_points = [(150, 150), (1130, 150), (1130, 570), (150, 570)]

# Initialize trackzone
trackzone = solutions.TrackZone(
    show=True,  # display the output
    region=region_points,  # pass region points
)

Remember that TrackZone reduces the points to their convex hull, so list them in order around the perimeter of the area you want to monitor.

Link to this sectionWhen should I use TrackZone instead of ObjectCounter or RegionCounter?#

All three solutions work with regions, but they answer different questions:

SolutionUse it toTypical output
TrackZoneTrack objects and monitor live occupancy inside a single convex zoneTracked IDs and total_tracks for the zone
ObjectCounterCount objects that cross a line or enter and leave a regionCumulative in and out counts
RegionCounterCount objects inside one or more arbitrary (including non-convex) regionsPer-region object counts

Choose TrackZone when you want continuous tracking inside one area, and RegionCounter when you need multiple zones or a non-convex shape.

Comments