This is a backup of an old project that focused on object detection and tracking over videos using YOLOv8. The project was based on the following tutorials:
- Murtaza's Workshop - Robotics and AI's Object Detection Tutorial
- Computer Vision Zone's Object Detection Course
The project was written in Python and uses the YOLOv8 object detection model.
Start a new virtual environment:
python3 -m venv venv
source venv/bin/activate # linux or windows WSL
.\venv\Scripts\activate # windows cmd
Then install the requirements:
pip install -r requirements.txt
Finally, run the jupyter notebook Object Detection.ipynb
within the virtual environment.
- Applying YOLOv8 on static image given by path specified in the "Parameters" section.
- Applying YOLOv8 on video given by path specified in the "Parameters" section.
- Instance identification with Abrewlay Sort library for tracking objects.
Notes
- The color of the box indicates the INSTANCE ID
Problems
- Inconsistent IDs: Occurs under occlusion or label changes
- Observe that the id of the truck 457 on the rightmost lane (cyan, with label "car") changed to id 473 (purple, with label "truck")
- Indicates that the library cannot provide a consistent ID for the same object across frames
- Multiple bounding boxes for the same object
- As artifacts of the original YOLOv8 detection (due to using the nano model)
- Instance identification with custom-implemented algorithm for tracking objects.
Goals
- Implementing a version of the object tracking algorithm that is more resistent to lost frames and flickering compared to the Abrewlay Sort library.
Features
- Label Accumulation
- Can accumulate labels from previous frames.
- The ids (colors of the frames) of the objects are more consistent, which can be checked visually
- The same truck now got a consistent id (no change in color indicates that)
- Bounding Box Merging
- Finds the closest bounding box to the previous frames (stored in a dictionary)
- Dictionary is cleared after a certain number of frames
- Only bounding boxes within a certain change in size and aspect ratio are merged by overwritting the same instance id
- Simple algorithm for counting cars across the line by masking the image before detection.
- Utilized the algorithm in sectino 3.5.2 for tracking objects to ensure that a car is not detected twice.