| # UAV Drone Detection and Tracking |
|
|
| ## Overview |
| This project detects UAV drones in video using a deep learning object detector and tracks them across frames using a Kalman filter. The output videos only include frames where the drone is present and overlay (1) the detector bounding box and (2) the 2D trajectory as a polyline. |
|
|
| ## Videos Used |
| - drone_video_1.mp4 (YouTube source): https://www.youtube.com/watch?v=DhmZ6W1UAv4 |
| - drone_video_2.mp4 (YouTube source): https://youtu.be/YrydHPwRelI |
|
|
| Frames were extracted using ffmpeg at 5 FPS. |
|
|
| ## Dataset (Drone Bounding Boxes) |
| I used a dataset that labels the drone itself with bounding boxes (not aerial imagery “from a drone”). |
| - Source: Roboflow (Drone Detection dataset) |
| - Export format: YOLOv8 |
| - Class: drone |
|
|
| ## Detector (Task 1) |
| - Model: Ultralytics YOLOv8n |
| - Training: Fine-tuned on the drone bounding-box dataset |
| - Best weights: `runs/detect/train4/weights/best.pt` |
| - Inference: ran detection on every extracted frame |
| - Deliverables created: |
| - Frames containing detections saved to: `artifacts/detections/<video_name>/` |
| - Detections saved to Parquet: |
| - `artifacts/detections/drone_video_1_detections.parquet` |
| - `artifacts/detections/drone_video_2_detections.parquet` |
|
|
| ## Kalman Filter Tracking (Task 2) |
| ### State Design |
| State vector: **[x, y, vx, vy]** |
| - (x, y): bounding box center in pixel coordinates |
| - (vx, vy): velocity in pixels/frame |
|
|
| Measurement vector: **[x, y]** from the detector. |
|
|
| ### Motion Model |
| A constant-velocity motion model is used: |
| - Predict step uses x_t = x_{t-1} + vx * dt, y_t = y_{t-1} + vy * dt |
| - Update step uses the detected center point when available |
|
|
| ### Handling Missed Detections |
| If the detector misses the drone temporarily, the tracker continues predicting without updates for a limited number of frames (max_missed). When detections return, the filter updates and continues the trajectory smoothly. |
| |
| ### Visualization |
| Each output frame overlays: |
| - The bounding box (detection if present; otherwise predicted) |
| - The 2D trajectory polyline connecting the estimated centers across frames |
| |
| |
| ## Failure Cases |
| - Small/far drones: detector can miss frames; Kalman prediction bridges short gaps. |
| - Motion blur / fast motion: bounding boxes may jitter; filter smooths but can drift if misses last too long. |
| - Background clutter: false positives can occur; increasing confidence threshold helps reduce them. |
| |
| |
| |