Are you sure you want to delete this access key?
comments | description | keywords |
---|---|---|
true | Discover how TrackZone leverages Ultralytics YOLO11 to precisely track objects within specific zones, enabling real-time insights for crowd analysis, surveillance, and targeted monitoring. | TrackZone, object tracking, YOLO11, Ultralytics, real-time object detection, AI, deep learning, crowd analysis, surveillance, zone-based tracking, resource optimization |
TrackZone specializes in monitoring objects within designated areas of a frame instead of the whole frame. Built on Ultralytics YOLO11, it integrates object detection and tracking specifically within zones for videos and live camera feeds. YOLO11'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.
Agriculture | Transportation |
---|---|
![]() |
![]() |
Plants Tracking in Field Using Ultralytics YOLO11 | Vehicles Tracking on Road using Ultralytics YOLO11 |
!!! example "TrackZone using YOLO11 Example"
=== "CLI"
```bash
# Run a trackzone example
yolo solutions trackzone show=True
# Pass a source video
yolo solutions trackzone show=True source="path/to/video/file.mp4"
# Pass region coordinates
yolo solutions trackzone show=True region=[(150, 150), (1130, 150), (1130, 570), (150, 570)]
```
=== "Python"
```python
import cv2
from ultralytics import solutions
cap = cv2.VideoCapture("path/to/video/file.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))
# Define region points
region_points = [(150, 150), (1130, 150), (1130, 570), (150, 570)]
# Video writer
video_writer = cv2.VideoWriter("object_counting_output.avi", cv2.VideoWriter_fourcc(*"mp4v"), fps, (w, h))
# Init TrackZone (Object Tracking in Zones, not complete frame)
trackzone = solutions.TrackZone(
show=True, # Display the output
region=region_points, # Pass region points
model="yolo11n.pt", # You can use any model that Ultralytics support, i.e. YOLOv9, YOLOv10
# line_width=2, # Adjust the line width for bounding boxes and text display
# classes=[0, 2], # If you want to count specific classes i.e. person and car with COCO pretrained model.
)
# Process video
while cap.isOpened():
success, im0 = cap.read()
if not success:
print("Video frame is empty or video processing has been successfully completed.")
break
im0 = trackzone.trackzone(im0)
video_writer.write(im0)
cap.release()
video_writer.release()
cv2.destroyAllWindows()
```
TrackZone
Here's a table with the TrackZone
arguments:
Name | Type | Default | Description |
---|---|---|---|
model |
str |
None |
Path to Ultralytics YOLO Model File |
region |
list |
[(150, 150), (1130, 150), (1130, 570), (150, 570)] |
List of points defining the object tracking region. |
line_width |
int |
2 |
Line thickness for bounding boxes. |
show |
bool |
False |
Flag to control whether to display the video stream. |
model.track
{% include "macros/track-args.md" %}
Tracking objects in a defined area or zone of a video frame is straightforward with Ultralytics YOLO11. 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/file.mp4" show=True
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/file.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))
# Define region points
region_points = [(150, 150), (1130, 150), (1130, 570), (150, 570)]
# Video writer
video_writer = cv2.VideoWriter("object_counting_output.avi", cv2.VideoWriter_fourcc(*"mp4v"), fps, (w, h))
# Init TrackZone (Object Tracking in Zones, not complete frame)
trackzone = solutions.TrackZone(
show=True, # Display the output
region=region_points, # Pass region points
model="yolo11n.pt",
)
# Process video
while cap.isOpened():
success, im0 = cap.read()
if not success:
print("Video frame is empty or video processing has been successfully completed.")
break
im0 = trackzone.trackzone(im0)
video_writer.write(im0)
cap.release()
video_writer.release()
cv2.destroyAllWindows()
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)]
# Init TrackZone (Object Tracking in Zones, not complete frame)
trackzone = solutions.TrackZone(
show=True, # Display the output
region=region_points, # Pass region points
)
Press p or to see the previous file or, n or to see the next file
Browsing data directories saved to S3 is possible with DAGsHub. Let's configure your repository to easily display your data in the context of any commit!
ultralytics is now integrated with AWS S3!
Are you sure you want to delete this access key?
Browsing data directories saved to Google Cloud Storage is possible with DAGsHub. Let's configure your repository to easily display your data in the context of any commit!
ultralytics is now integrated with Google Cloud Storage!
Are you sure you want to delete this access key?
Browsing data directories saved to Azure Cloud Storage is possible with DAGsHub. Let's configure your repository to easily display your data in the context of any commit!
ultralytics is now integrated with Azure Cloud Storage!
Are you sure you want to delete this access key?
Browsing data directories saved to S3 compatible storage is possible with DAGsHub. Let's configure your repository to easily display your data in the context of any commit!
ultralytics is now integrated with your S3 compatible storage!
Are you sure you want to delete this access key?