{"id":31067290,"url":"https://github.com/mtgsoftworks/uav-advanced-tracking-system","last_synced_at":"2026-05-02T23:32:33.050Z","repository":{"id":313412402,"uuid":"1051342432","full_name":"mtgsoftworks/UAV-Advanced-Tracking-System","owner":"mtgsoftworks","description":"Real-time UAV detection \u0026 tracking system powered by YOLOv8, OpenCV, and PID control","archived":false,"fork":false,"pushed_at":"2025-09-05T20:37:12.000Z","size":50,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-05T22:24:02.397Z","etag":null,"topics":["deep-learning","drone-tracking","object-detection","opencv","pytorch","real-time-tracking","uav","yolov8"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mtgsoftworks.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-05T20:29:47.000Z","updated_at":"2025-09-05T20:37:16.000Z","dependencies_parsed_at":"2025-09-05T22:24:03.723Z","dependency_job_id":"ea4b417d-49ba-4f5d-b4dc-e4379ceb0a81","html_url":"https://github.com/mtgsoftworks/UAV-Advanced-Tracking-System","commit_stats":null,"previous_names":["mtgsoftworks/uav-advanced-tracking-system"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/mtgsoftworks/UAV-Advanced-Tracking-System","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mtgsoftworks%2FUAV-Advanced-Tracking-System","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mtgsoftworks%2FUAV-Advanced-Tracking-System/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mtgsoftworks%2FUAV-Advanced-Tracking-System/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mtgsoftworks%2FUAV-Advanced-Tracking-System/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mtgsoftworks","download_url":"https://codeload.github.com/mtgsoftworks/UAV-Advanced-Tracking-System/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mtgsoftworks%2FUAV-Advanced-Tracking-System/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275312966,"owners_count":25442563,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-15T02:00:09.272Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deep-learning","drone-tracking","object-detection","opencv","pytorch","real-time-tracking","uav","yolov8"],"created_at":"2025-09-15T19:57:47.766Z","updated_at":"2025-09-15T19:57:51.499Z","avatar_url":"https://github.com/mtgsoftworks.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🚁 UAV Advanced Tracking System\r\n\r\n[![Python Version](https://img.shields.io/badge/python-3.10+-blue.svg)](https://python.org)\r\n[![YOLO](https://img.shields.io/badge/YOLO-v8s-green.svg)](https://github.com/ultralytics/ultralytics)\r\n[![OpenCV](https://img.shields.io/badge/OpenCV-4.12+-red.svg)](https://opencv.org)\r\n[![PyTorch](https://img.shields.io/badge/PyTorch-2.7+-orange.svg)](https://pytorch.org)\r\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)\r\n\r\n**UAV Advanced Tracking System** is an advanced computer vision system developed for UAV/drone detection and tracking. It performs real-time UAV tracking using YOLOv8s deep learning model and OpenCV tracker algorithms. The system is equipped with optimized parameters based on academic research findings and a PID control system.\r\n\r\n## 🎯 Features\r\n\r\n### 🔥 **Dual Tracking Approach**\r\n- **YOLO-only Tracking**: YOLO detection + Kalman Filter in every frame\r\n- **OpenCV Tracker**: 7 different classical tracking algorithms (CSRT, KCF, MOSSE, MIL, BOOSTING, MEDIANFLOW, TLD)\r\n\r\n### 🧠 **AI Integration**\r\n- **YOLOv8s** custom model support\r\n- **GPU/CPU** automatic optimization\r\n- **Confidence threshold** academic optimization (20% main, 15% tracking)\r\n- **NMS IOU threshold** adjustable (0.4 optimized)\r\n\r\n### 🎮 **Advanced Control System**\r\n- **PID Controller** dynamic gain adjustment\r\n- **Kalman Filter** smooth tracking\r\n- **ROI scanning** system (4 region optimized)\r\n- **Adaptive threshold** (far/near distance)\r\n\r\n### 📊 **Performance Monitoring**\r\n- Real-time **FPS** indicator\r\n- **Confidence tracking** and statistics\r\n- **Bbox history** and smooth filtering\r\n- **Detection timeout** control\r\n\r\n## 🚀 Quick Start\r\n\r\n### 📋 Requirements\r\n\r\n- **Python 3.10+**\r\n- **Windows 10/11** (tested)\r\n- **CUDA compatible GPU** (optional, for acceleration)\r\n- **Webcam or video file**\r\n\r\n### ⚡ Installation\r\n\r\n1. **Clone the repository:**\r\n```bash\r\ngit clone https://github.com/yourusername/uav-tracking-system.git\r\ncd uav-tracking-system\r\n```\r\n\r\n2. **Create virtual environment:**\r\n```bash\r\npython -m venv uav_env\r\n# For Windows:\r\n.\\uav_env\\Scripts\\activate\r\n# For Linux/Mac:\r\nsource uav_env/bin/activate\r\n```\r\n\r\n3. **Install dependencies:**\r\n```bash\r\npip install --upgrade pip\r\npip install opencv-python torch ultralytics numpy opencv-contrib-python\r\n```\r\n\r\n4. **Alternative - Installation with requirements:**\r\n```bash\r\npip install -r requirements.txt\r\n```\r\n\r\n### 🎬 Usage\r\n\r\n#### **YOLO-only Tracker (Recommended):**\r\n```bash\r\npython uav_tracking_yolo.py\r\n```\r\n\r\n#### **OpenCV Tracker Version:**\r\n```bash\r\npython uav_tracking_opencv_trackers.py\r\n```\r\n\r\n### 📹 Video Configuration\r\n\r\nPlace your video files in the `Scenes/` folder:\r\n```\r\nUAV/\r\n├── Scenes/\r\n│   ├── scene1.mp4\r\n│   ├── scene2.mp4\r\n│   └── ...\r\n├── best.pt (YOLO model)\r\n└── ...\r\n```\r\n\r\n## 🔧 Technical Details\r\n\r\n### 🎯 **Optimal Threshold Values**\r\n\r\nThreshold values optimized according to academic research findings:\r\n\r\n| Parameter | Value | Description |\r\n|-----------|-------|-------------|\r\n| **Main Detection Confidence** | 20% | Optimal for initial detection |\r\n| **Tracking Confidence** | 15% | More sensitive during tracking |\r\n| **IOU Threshold (NMS)** | 0.4 | Non-Maximum Suppression |\r\n| **Minimum Bbox Size** | 2.5% frame | For small UAVs |\r\n| **Target Area** | 1.5% frame | PID control reference |\r\n\r\n### 📊 **ROI Scanning System**\r\n\r\nSystematic scanning with 4 large ROI regions:\r\n```\r\n┌─────────┬─────────┐\r\n│  ROI 1  │  ROI 2  │\r\n│ (Top-L) │ (Top-R) │\r\n├─────────┼─────────┤\r\n│  ROI 3  │  ROI 4  │\r\n│ (Bot-L) │ (Bot-R) │\r\n└─────────┴─────────┘\r\n```\r\n\r\n- **ROI Size**: 640x360 (with overlap)\r\n- **Scanning Speed**: 12 frame/ROI\r\n- **Total Scan**: ~1.6 seconds/cycle\r\n\r\n### 🎮 **PID Control System**\r\n\r\nAdaptive PID gains based on distance:\r\n\r\n| Distance | Kp | Ki | Kd | Kf | Usage |\r\n|----------|----|----|----|----|-------|\r\n| **Far** | 300 | 35 | 80 | 1480 | Distant targets |\r\n| **Close** | 200 | 50 | 120 | 1480 | Near targets |\r\n\r\n### 🧠 **Kalman Filter Configuration**\r\n\r\n8-state Kalman filter (x, y, w, h, vx, vy, vw, vh):\r\n- **Process Noise**: 5e-3 (low noise, stable tracking)\r\n- **Measurement Noise**: 1e-1 (YOLO detection reliability)\r\n- **Prediction Model**: Constant velocity\r\n\r\n## 📈 **OpenCV Tracker Comparison**\r\n\r\nBased on [LearnOpenCV](https://learnopencv.com/object-tracking-using-opencv-cpp-python/) reference, tracker performance:\r\n\r\n| Tracker | Accuracy | Speed | UAV Suitability | Recommended |\r\n|---------|----------|-------|-----------------|-------------|\r\n| **CSRT** | ⭐⭐⭐⭐⭐ | ⭐⭐ | 🟢 Best | ✅ Precise tracking |\r\n| **KCF** | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ | 🟢 Good | ✅ General purpose |\r\n| **MOSSE** | ⭐⭐⭐ | ⭐⭐⭐⭐⭐ | 🟡 Speed focused | ⚡ Real-time |\r\n| **MIL** | ⭐⭐⭐ | ⭐⭐⭐ | 🟡 Basic | 📚 Simple |\r\n| **TLD** | ⭐⭐⭐⭐ | ⭐⭐ | 🟡 Occlusion | 🔍 Experimental |\r\n| **MEDIANFLOW** | ⭐⭐⭐ | ⭐⭐⭐ | 🔴 Not suitable | ❌ Slow motion only |\r\n| **BOOSTING** | ⭐⭐ | ⭐⭐ | 🔴 Not recommended | ❌ Outdated |\r\n\r\n## 🎨 **User Interface**\r\n\r\n### 🎯 **YOLO-only Version**\r\n- **Green box**: UAV tracking active\r\n- **Yellow area**: Target region\r\n- **Red line**: Center-target connection\r\n- **Control panel**: PID values real-time\r\n- **ROI indicator**: Scanning mode\r\n\r\n### 🎮 **Control Keys**\r\n- `Q`: Exit\r\n- `R`: Tracking reset\r\n- `S`: Screenshot (YOLO version only)\r\n\r\n### 📊 **Information Indicators**\r\n- **FPS**: Real-time performance\r\n- **Confidence**: Detection confidence\r\n- **PID Values**: Aileron, Elevator, Throttle\r\n- **Target Area**: Current/target area ratio\r\n\r\n## 🔬 **Academic Optimizations**\r\n\r\n### 📚 **Confidence Threshold Research**\r\n\r\nLiterature review results:\r\n- **YOLOv8 Default**: 0.4 (too high, UAVs missed)\r\n- **LMWP-YOLO Study**: 0.25 recommended\r\n- **UAV Detection Papers**: 0.2-0.25 range optimal\r\n- **This Project**: 0.2 (main), 0.15 (tracking)\r\n\r\n### 🎯 **ROI Optimization**\r\n\r\n- **Old**: 6 small ROI (3x2 grid) → Confusing scanning\r\n- **New**: 4 large ROI (2x2 grid) → 40% more efficient\r\n- **Overlap**: 100px → Edge case handling\r\n- **Frame/ROI**: 15 → 12 frame (20% speedup)\r\n\r\n## 🚀 **Performance Benchmarks**\r\n\r\n### 💻 **Test System**\r\n- **CPU**: Intel i7 series\r\n- **GPU**: CUDA compatible (optional)\r\n- **RAM**: 8GB+ recommended\r\n- **Video**: 1280x720 @ 30fps\r\n\r\n### 📊 **Performance Results**\r\n\r\n| Mode | FPS | CPU Usage | GPU Usage | Detection Rate |\r\n|------|-----|-----------|-----------|----------------|\r\n| **YOLO-only** | 15-25 | 60-80% | 40-60% | 95%+ |\r\n| **CSRT Tracker** | 20-30 | 40-60% | 20-40% | 85%+ |\r\n| **MOSSE Tracker** | 35-45 | 30-50% | 15-30% | 80%+ |\r\n\r\n### 🎯 **Detection Accuracy**\r\n\r\nOn test videos:\r\n- **Confidence Range**: 31% - 94%\r\n- **Average Confidence**: 76%\r\n- **Detection Success**: 92%\r\n- **False Positive**: \u003c5%\r\n- **Tracking Loss**: \u003c8%\r\n\r\n## 🗂️ **Project Structure**\r\n\r\n```\r\nUAV/\r\n├── 📁 Scenes/              # Video files\r\n│   ├── scene1.mp4\r\n│   └── scene2.mp4\r\n├── 📁 uav_env/             # Python virtual environment\r\n├── 🐍 uav_tracking_yolo.py   # Main YOLO tracker\r\n├── 🐍 uav_tracking_opencv_trackers.py  # OpenCV trackers\r\n├── 🐍 test_trackers.py       # Tracker test script\r\n├── 🧠 best.pt               # YOLOv8s custom model\r\n├── 📋 requirements.txt      # Python dependencies\r\n└── 📖 README.md             # This file\r\n```\r\n\r\n## 🔧 **Advanced Configuration**\r\n\r\n### ⚙️ **YOLO Model Settings**\r\n\r\n```python\r\n# Model parameters\r\nCONF_THRESHOLD = 0.2        # Main detection\r\nTRACK_CONF_THRESHOLD = 0.15 # Tracking detection\r\nIOU_THRESHOLD = 0.4         # NMS threshold\r\nMAX_DET = 100              # Maximum detections\r\n```\r\n\r\n### 🎮 **PID Tuning**\r\n\r\n```python\r\n# Far distance gains\r\ngains_far = {\r\n    'Kp': 300,    # Proportional gain\r\n    'Ki': 35,     # Integral gain  \r\n    'Kd': 80,     # Derivative gain\r\n    'Kf': 1480    # Feedforward\r\n}\r\n\r\n# Near distance gains\r\ngains_close = {\r\n    'Kp': 200,    # Softer control\r\n    'Ki': 50,     # Higher integral\r\n    'Kd': 120,    # Higher derivative\r\n    'Kf': 1480    # Constant feedforward\r\n}\r\n```\r\n\r\n### 🔍 **ROI Customization**\r\n\r\n```python\r\n# ROI size settings\r\nroi_width = frame_width // 2   # 640px default\r\nroi_height = frame_height // 2 # 360px default\r\noverlap = 100                  # Overlap pixels\r\nROI_SCAN_FRAMES = 12          # Frame/ROI\r\n```\r\n\r\n## 🛠 **Troubleshooting**\r\n\r\n### ❌ **Common Errors**\r\n\r\n1. **\"CUDA out of memory\"**\r\n   ```bash\r\n   # Switch to CPU mode\r\n   device = \"cpu\"\r\n   ```\r\n\r\n2. **\"TrackerCSRT_create not found\"**\r\n   ```bash\r\n   # Install OpenCV-contrib\r\n   pip install opencv-contrib-python\r\n   ```\r\n\r\n3. **\"Video file cannot be opened\"**\r\n   ```bash\r\n   # Check video path\r\n   VIDEO_PATH = \"Scenes/scene1.mp4\"\r\n   ```\r\n\r\n### 🔧 **Performance Tuning**\r\n\r\n1. **GPU Memory Optimization**:\r\n   ```python\r\n   torch.cuda.empty_cache()  # Clear memory\r\n   ```\r\n\r\n2. **Frame Rate Optimization**:\r\n   ```python\r\n   cv2.waitKey(1)  # Reduce display delay\r\n   ```\r\n\r\n3. **Detection Frequency**:\r\n   ```python\r\n   # Detect every 2nd frame\r\n   if frame_count % 2 == 0:\r\n       detect()\r\n   ```\r\n\r\n## 🤝 **Contributing**\r\n\r\n1. **Fork** it\r\n2. Create **feature branch**: `git checkout -b amazing-feature`\r\n3. **Commit** changes: `git commit -m 'Add amazing feature'`\r\n4. **Push** to branch: `git push origin amazing-feature`\r\n5. Open **Pull Request**\r\n\r\n### 🛠 **Development Setup**\r\n\r\n```bash\r\n# Development dependencies\r\npip install pytest black flake8 mypy\r\n```\r\n\r\n### 🧪 **Testing**\r\n\r\n```bash\r\n# Tracker tests\r\npython test_trackers.py\r\n\r\n# Unit tests (future)\r\npytest tests/\r\n```\r\n\r\n## 📚 **References and Resources**\r\n\r\n### 📖 **Academic Sources**\r\n- [LearnOpenCV Object Tracking Guide](https://learnopencv.com/object-tracking-using-opencv-cpp-python/)\r\n- YOLOv8 Official Documentation\r\n- OpenCV Tracking Algorithms Documentation\r\n- UAV Detection Research Papers\r\n\r\n### 🔗 **Technical Documentation**\r\n- [Ultralytics YOLOv8](https://github.com/ultralytics/ultralytics)\r\n- [OpenCV Python Tutorials](https://docs.opencv.org/4.x/d6/d00/tutorial_py_root.html)\r\n- [PyTorch Documentation](https://pytorch.org/docs/stable/index.html)\r\n\r\n### 🎯 **Confidence Threshold Research**\r\n- LMWP-YOLO: Optimized threshold studies\r\n- UAV Detection Papers: 0.2-0.25 optimal range\r\n- Real-world deployment findings\r\n\r\n## 📞 **Contact**\r\n\r\n- **Email**: your.email@domain.com\r\n- **GitHub**: [@yourusername](https://github.com/yourusername)\r\n- **LinkedIn**: [Your Profile](https://linkedin.com/in/yourprofile)\r\n\r\n## 📄 **License**\r\n\r\nThis project is licensed under the **MIT License**. See the [LICENSE](LICENSE) file for details.\r\n\r\n## 🏆 **Acknowledgments**\r\n\r\n- **YOLOv8** team\r\n- **OpenCV** community  \r\n- **LearnOpenCV** for educational materials\r\n- **PyTorch** framework\r\n- Academic research contributions\r\n\r\n## 👨‍💻 **Author**\r\n\r\n**Mesut Taha Güven** - *Lead Developer \u0026 Researcher*\r\n- GitHub: [@mtgsoftworks](https://github.com/mtgsoftworks)\r\n- Email: mtg@duck.com\r\n\r\n*Specialized in computer vision, UAV systems, and real-time tracking algorithms. Passionate about combining academic research with practical applications.*\r\n\r\n## 📊 **Changelog**\r\n\r\n### v2.0 (Latest)\r\n- ✅ Dual tracking system implementation\r\n- ✅ Academic optimization integration\r\n- ✅ OpenCV tracker fallback mechanism\r\n- ✅ Improved ROI scanning\r\n- ✅ Enhanced PID control\r\n\r\n### v1.0 (Initial)\r\n- ✅ Basic YOLO detection\r\n- ✅ Simple tracking implementation\r\n- ✅ ROI scanning prototype\r\n\r\n---\r\n\r\n**⭐ Don't forget to star the project if you liked it!**\r\n\r\n**🚁 UAV Advanced Tracking System - Where AI Meets Precision**\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmtgsoftworks%2Fuav-advanced-tracking-system","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmtgsoftworks%2Fuav-advanced-tracking-system","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmtgsoftworks%2Fuav-advanced-tracking-system/lists"}