A real-time object detection and tracking system using YOLO 11 and Deep SORT.
This project implements real-time object detection and tracking using YOLO and Deep SORT. The tracking algorithm ensures persistent IDs for detected objects and handles detection across video frames.
- Real-time object detection using YOLO.
- Deep SORT object tracking with ID persistence across frames.
- Customizable detection confidence threshold.
- Aspect ratio maintained using padding for resized images.
- Filter to track only objects that appear in the center of the frame.
Make sure to install the following Python libraries:
pip install opencv-python torch deep_sort_realtime numpy
- opencv-python - For handling video frames and drawing bounding boxes.
- torch - To load and run the YOLO model.
- deep_sort_realtime - For object tracking across frames.
- numpy - General-purpose array operations.
- Clone the repository:
- Install the required Python libraries:
- Ensure your YOLO model weights are placed in the correct directory and update the
MODEL_PATH
inyolo_detection_tracker.py
accordingly.
git clone https://github.com/iamrukeshduwal/yolov11_real_time_object_detection_with_DeepSORT.git
cd yolov11_real_time_object_detection_with_DeepSORT
pip install -r requirements.txt
Run the following command to start detecting and tracking objects in a video:
python yolo_detection_tracker.py
Modify the video path and parameters (e.g., confidence threshold) in yolo_detection_tracker.py
to suit your needs.
The main script that handles video input, object detection with YOLO, and tracking with Deep SORT.
detector = YoloDetector(model_path=MODEL_PATH, confidence=0.2)
tracker = Tracker()
Tracks objects, maintains their IDs, and only tracks objects in the middle of the frame.
Contains the YoloDetector class that loads the YOLO model and performs object detection.
detections = detector.detect(frame)
Defines the Tracker class, which implements object tracking using the Deep SORT algorithm.
tracking_ids, boxes = tracker.track(detections, resized_frame)
You can change the detection confidence threshold in the YoloDetector
by modifying the following line in yolo_detection_tracker.py
:
detector = YoloDetector(model_path=MODEL_PATH, confidence=0.3)
The current implementation only tracks objects detected in the middle of the frame. You can adjust this behavior in yolo_detection_tracker.py
by modifying the center filtering logic.
This project is licensed under the MIT License. See the LICENSE
file for more details.