This project aims to perform real-time object tracking using different Single Object Tracking (SOT) algorithms provided by OpenCV. The user selects the object to be tracked in the first frame captured from the camera, and tracking begins with the selected algorithm.
- Real-time object tracking with Python (OpenCV)
- ROI (Region of Interest) selection from the user
- Display of FPS and algorithm name on the screen
- Warning message if tracking fails
- Can run from camera or video file
I have tested and experienced the following OpenCV SOT algorithms:
- BOOSTING
- MIL
- KCF
- TLD
- MEDIANFLOW
- MOSSE
- CSRT
-
Install the required packages:
pip install opencv-contrib-python -
Run the
Single Object Tracker.pyfile:python Single\ Object\ Tracker.py -
When the program starts, select the object you want to track and confirm.
-
During tracking, the FPS and the selected algorithm name will be displayed on the screen.
-
Press
qto exit tracking.
- You can change the algorithm by modifying the
tracker_typevariable in the code. - Make sure the
opencv-contrib-pythonpackage is installed. - The performance of the algorithms may vary depending on your hardware and the characteristics of the object being tracked.
This project also includes a simple real-time Multi-Object Tracker (MOT) using OpenCV’s built-in MultiTracker class. Users can press the s key during video playback to select and add multiple objects for tracking simultaneously. The tracker updates all bounding boxes frame by frame and displays them in real-time.
- Track multiple objects using selected bounding boxes
- Add new objects dynamically by pressing s and selecting a new ROI
- Supports multiple OpenCV trackers (BOOSTING, MIL, KCF, TLD, etc.)
- Displays tracking success or failure for each frame
- Works with webcam or video input
You can change the tracker algorithm in the code by switching to: cv2.legacy.TrackerKCF_create(), cv2.legacy.TrackerCSRT_create() etc.
- Press s: Select and add a new object to track
- Press q: Quit tracking and close the video window