Real-time Edge Vision Tutorial: Process multi-channel RTSP video streams, annotate bounding boxes, and track objects across spatial polygonal zones using Ultralytics YOLOv11 and Supervision.
Step 1: Initialize YOLOv11 & Supervision Polygon Zone
from ultralytics import YOLO
import supervision as sv
import cv2
model = YOLO("yolov8n.pt")
tracker = sv.ByteTrack()
zone = sv.PolygonZone(polygon=zone_polygon_coordinates)
annotator = sv.BoxAnnotator()
Step 2: Process Video Stream Frame Loop
cap = cv2.VideoCapture("rtsp://admin:stream@192.168.1.100/live")
while cap.isOpened():
ret, frame = cap.read()
if not ret: break
results = model(frame)[0]
detections = sv.Detections.from_ultralytics(results)
detections = tracker.update_with_detections(detections)
in_zone = zone.trigger(detections=detections)
annotated_frame = annotator.annotate(scene=frame, detections=detections)
cv2.imshow("Real-Time Analytics", annotated_frame)
COMMENTS (0)
Join the discussion on AI engineering and technical research.