Gerçek zamanlı yüz takip sistemi - OpenCV kullanarak webcam'den canlı yüz takibi yapın. CSRT, KCF ve MOSSE algoritmaları ile hızlı ve hassas takip imkanı sunar.
A high-performance, real-time face tracking system using multiple tracking algorithms (CSRT, KCF, MOSSE). Easy-to-use interface for face detection and tracking with webcam support.
- 🎯 Multiple Tracker Options: CSRT, KCF, and MOSSE algorithms
- ⚡ Real-time Performance: Optimized for live webcam tracking
- 🔍 Smart Face Validation: Periodic validation to prevent drift
- 🎨 Clean API: Simple, intuitive interface
- 📹 Webcam Support: Built-in camera integration
| Tracker | Speed | Accuracy | Use Case |
|---|---|---|---|
| MOSSE | ⚡⚡⚡ Fastest | ⭐⭐ Good | Fast movements, low-end hardware |
| KCF | ⚡⚡ Fast | ⭐⭐⭐ Better | Recommended - Balanced performance |
| CSRT | ⚡ Slower | ⭐⭐⭐⭐ Best | Maximum accuracy, powerful hardware |
# Clone the repository
git clone https://github.com/Keremdagli/FaceTracking.git
cd FaceTracking
# Install dependencies
pip install -r requirements.txtfrom face_tracker import run_tracker
# Run with KCF tracker (recommended)
run_tracker(tracker_type='KCF', window_title='My Face Tracker')from face_tracker import FaceTracker
import cv2
tracker = FaceTracker(tracker_type='KCF')
cap = cv2.VideoCapture(0)
while True:
ret, frame = cap.read()
if not ret:
break
# Your tracking logic here
# See examples for complete implementation
cv2.imshow('Tracking', frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()The examples/ directory contains ready-to-run examples for each tracker:
# Run from project root directory
python examples/kcf_example.py # KCF - Recommended
python examples/csrt_example.py # CSRT - Most accurate
python examples/mosse_example.py # MOSSE - Fastest
# Or run directly from examples directory
cd examples
python mosse_example.pyPress q to quit any example.
- Detection: Uses Haar Cascade for initial face detection
- Tracking: Switches to selected tracker (CSRT/KCF/MOSSE) for real-time tracking
- Validation: Periodically validates tracked region to prevent drift
- Recovery: Automatically redetects face if tracking is lost
- Python 3.7+
- OpenCV with contrib modules (opencv-contrib-python)
- Webcam
FaceTracking/
├── face_tracker.py # Main module
├── haarcascade_frontalface_default.xml # Face detection model
├── examples/
│ ├── csrt_example.py # CSRT tracker example
│ ├── kcf_example.py # KCF tracker example
│ └── mosse_example.py # MOSSE tracker example
├── requirements.txt
└── README.md
FaceTracker(tracker_type='KCF')Methods:
detect_face(frame): Initial face detectiontrack(frame): Track face in current framevalidate_face(frame, box): Validate tracked regionreset(): Reset tracker state
run_tracker(tracker_type='KCF', window_title='Face Tracking')Parameters:
tracker_type: 'CSRT', 'KCF', or 'MOSSE'window_title: Display window title
- Use MOSSE for low-end hardware or fast movements
- Use KCF for general purpose tracking (recommended)
- Use CSRT when accuracy is critical
- Ensure good lighting for better detection
- Keep face within frame for consistent tracking
Camera not opening:
# Try different camera index
cap = cv2.VideoCapture(0) # or 1, 2, 3, etc.Tracker not found error:
pip uninstall opencv-python
pip install opencv-contrib-pythonContributions are welcome! Please feel free to submit a Pull Request.
- OpenCV team for excellent computer vision library
- Haar Cascade classifiers for face detection