Project Case Study  ·  Computer Vision

Drone-Based Traffic Analysis
using YOLOv8 and Multi-Object Tracking

Real-time object detection and tracking in aerial footage.

Built a real-time computer vision pipeline to detect and track multiple objects in drone footage of a university campus.

At a Glance

Project Snapshot

Domain

Computer Vision

Dataset

Aerial Drone Footage

Detection Model

YOLOv8 (Ultralytics)

Tracking

BoT-SORT / ByteTrack

Environment

University Campus

Output

Annotated Video + CSV Logs

Demo

MODEL OUTPUT

Model output showing real-time detection and tracking of objects in aerial drone footage

Background

Project Overview

This project focuses on analyzing aerial drone footage of a university campus using deep learning. The system detects and tracks objects such as people, vehicles, and other moving entities in real time. It is designed to work in complex environments where objects are small, partially occluded, and constantly moving.

The pipeline runs frame-by-frame, applies YOLOv8 for detection, assigns persistent tracking IDs across frames, and generates both annotated video output and structured CSV logs for downstream analysis.

Deliverables

What I Built

Real-time object detection using YOLOv8

Multi-object tracking using BoT-SORT and ByteTrack

Frame-by-frame video processing pipeline

Annotated video generation with bounding boxes and persistent IDs

Structured CSV logging of detections for frame-wise tracking data

Under the Hood

Technical Breakdown

YOLOv8 for Detection

Used Ultralytics YOLOv8 for real-time bounding box detection across each video frame, optimized for small and distant aerial objects.

Persistent Tracking IDs

Applied BoT-SORT and ByteTrack to maintain consistent object IDs across frames, even through partial occlusion and re-entries.

Parameter Tuning

Tuned confidence threshold, IoU, and image size specifically for aerial perspective where objects appear small and densely packed.

Class Filtering

Filtered detection to specific classes (person, car, truck, bus, bicycle) to reduce noise and focus on traffic-relevant objects.

Structured Output

Generated both annotated video files and CSV logs with frame number, object ID, class, and bounding box coordinates for analysis.

Small Object Optimization

Increased input image resolution and applied multi-scale inference to improve detection of people and vehicles far from the camera.

Implementation

Core Tracking Call

track.py
1from ultralytics import YOLO
2import cv2
3 
4model = YOLO("best.pt")
5 
6cap = cv2.VideoCapture("university_park.mp4")
7 
8while True:
9 ret, frame = cap.read()
10 if not ret:
11 break
12 
13 results = model.track(
14 frame,
15 persist=True,
16 tracker="botsort.yaml",
17 conf=0.15,
18 iou=0.45,
19 imgsz=1536
20 )
21 
22 for result in results:
23 if result.boxes is None:
24 continue
25 
26 for box in result.boxes:
27 cls = int(box.cls[0])
28 conf = float(box.conf[0])
29 track_id = int(box.id[0]) if box.id is not None else None
30 
31 x1, y1, x2, y2 = map(int, box.xyxy[0])
32 
33 label = f"{cls} {conf:.2f}"
34 if track_id is not None:
35 label += f" ID:{track_id}"
36 
37 cv2.rectangle(frame, (x1, y1), (x2, y2), (0,255,0), 2)
38 cv2.putText(frame, label, (x1, y1-10),
39 cv2.FONT_HERSHEY_SIMPLEX, 0.6, (0,255,0), 2)
40 
41 cv2.imshow("Tracking", frame)
42 if cv2.waitKey(1) & 0xFF == 27:
43 break
44 
45cap.release()
46cv2.destroyAllWindows()

Engineering Reality

Challenges and How I Addressed Them

Small Objects in Aerial View

People and vehicles filmed from altitude appear very small in the frame. Standard detection settings miss them entirely without resolution adjustments.

False Positives in Early Versions

Dense tree canopies and rooftop structures were misclassified as vehicles in early runs. Confidence threshold tuning and class filtering resolved most of this.

Tracking Instability During Occlusion

Objects passing behind trees or other obstructions caused ID switches and tracking drops. ByteTrack's re-identification logic reduced these significantly.

Iterative Parameter Tuning

Confidence, IoU, and image resolution all required manual tuning for aerial data. No out-of-the-box preset worked well without domain-specific adjustments.

Outcomes

Results

↑

Detection Accuracy

Improved accuracy for vehicles and people after resolution and threshold tuning.

↓

ID Switches

Fewer tracking identity switches across frames with BoT-SORT re-identification.

↓

False Positives

Significantly reduced misclassifications after tuning and class filtering.

✓

Clean Output

Annotated video and CSV logs ready for downstream traffic analysis.

The end-to-end pipeline runs on real drone footage and produces both human-readable annotated video and machine-readable CSV data suitable for traffic flow analysis, density estimation, and behavioral pattern detection.

Tools & Technologies

Tech Stack

Python
YOLOv8
Ultralytics
OpenCV
BoT-SORT
ByteTrack
Pandas

Explore More

Interested in my work?

I build real-world AI and computer vision systems. Check out my other projects or get in touch.