Skip to main content

Project: YOLO Object Tracking

· 3 min read

View Project

Python Ultralytics YOLO Artificial Intelligence (AI) Object Detection Last Updated

Overview

This is a backup of an old project that focused on object detection and tracking over videos using YOLOv8.

Applied Abrewley's Sort Library and self-implemented instance label assigning function based on maximum overlap to stablize the labelled id on each car moving across frames.

Backup of Old Project (June 2023)

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:

The project was written in Python and uses the YOLOv8 object detection model.

About the Project / Key Features

Static Image Detection Section 3.2

  • Applying YOLOv8 on static image given by path specified in the "Parameters" section.

alt text

Video Detection Section 3.4

  • Applying YOLOv8 on video given by path specified in the "Parameters" section.

alt text

Instance Tracking with Abrewlay Sort Section 3.5.1 Abrewlay Sort

  • Instance identification with Abrewlay Sort library for tracking objects.

alt text

Notes

  • The color of the box indicates the INSTANCE ID

Problems

  1. 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
  2. Multiple bounding boxes for the same object
    • As artifacts of the original YOLOv8 detection (due to using the nano model)

Custom Tracking Algorithm Section 3.5.2

  • Instance identification with custom-implemented algorithm for tracking objects.

alt text

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

  1. 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)
  2. 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

Car Counter Section 3.6

alt text

  • 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.