con-Detection

What it does

con-Detection is a cone-detection system built on YOLOv5 that processes a video file frame by frame, drawing bounding boxes around traffic cones in each frame. It is aimed at applications such as autonomous-driving tests and robotics navigation where reliable cone detection is a prerequisite for path planning. The system runs in a Google Colab notebook, leveraging Colab's hosted GPU runtime without requiring any local hardware setup.

How it works

Running YOLOv5 over a video frame by frame

The notebook loads a pre-trained YOLOv5 model using the PyTorch Hub interface. It then opens the input video with OpenCV and iterates over each frame in a loop. For each frame, YOLOv5 runs inference and returns a set of bounding-box predictions with class labels and confidence scores. The notebook draws the boxes and labels onto the frame, assembles the annotated frames into an output video, and saves it. The entire detection loop — read frame, run model, draw boxes, write frame — is the core of the system.

Why Google Colab was chosen

YOLOv5 inference on video is GPU-intensive, and Colab provides a free hosted GPU runtime with CUDA already configured. The notebook format also makes it easy to walk through each step of the pipeline — model loading, video processing, result visualization — in a linear, documented way that is accessible to someone studying the approach without needing to set up a local deep-learning environment.

Design decisions

  • YOLOv5 was selected for its balance of detection speed and accuracy at the scales relevant to traffic-cone detection, and because its PyTorch Hub integration makes it straightforward to load a pre-trained checkpoint.
  • The sample video is kept out of the repository because of its file size; the notebook documents the expected format and resolution so users can supply their own footage.
  • OpenCV's VideoCapture and VideoWriter APIs handle the frame loop and output assembly, keeping the video I/O code separate from the detection logic.
  • Frame-by-frame processing rather than batch processing keeps memory usage predictable and makes it easy to inspect individual frames during development.

Stack

LayerTechnology
LanguagePython 3.7+
AI/MLYOLOv5
AI/MLPyTorch (torch, torchvision, torchaudio)
LanguageOpenCV (opencv-python-headless 4.5.2.52)
LibraryJupyter Notebook
LibraryGoogle Colab

Source

View con-Detection on GitHub →