Skip to content

About

πŸš€ Object Detection with OpenCV & YOLO | Interactive UI 🎯

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Latest commit

Β 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Object Detection with OpenCV & YOLO | Interactive UI 🎯

πŸ” Real-time Object Detection using YOLO and OpenCV with a scrollable, interactive UI for selecting object categories dynamically.


πŸ“Έ Demo

image


🎯 Project Overview

This project implements real-time object detection using YOLO (You Only Look Once) and OpenCV in Python. It features: βœ… Deep Learning-based Object Detection (YOLOv4-tiny)
βœ… Customizable Object Selection via UI Buttons
βœ… Scrollable Category Panel (Supports 80+ object categories)
βœ… Optimized UI (Compact, modern, and business-ready)
βœ… Fast and Efficient (Utilizing OpenCV’s DNN module)


πŸ“‚ Project Structure

opencv-object-detection-ui/
 β”œβ”€β”€ dnn_model/                  # YOLO model files
 β”‚    β”œβ”€β”€ yolov4-tiny.cfg
 β”‚    β”œβ”€β”€ yolov4-tiny.weights
 β”‚    β”œβ”€β”€ classes.txt
 β”œβ”€β”€ main4.py                     # Main object detection script
 β”œβ”€β”€ gui_buttons.py                # GUI button system with scrolling support
 β”œβ”€β”€ README.md                     # Project documentation

πŸ› οΈ Installation & Setup

πŸ”Ή 1. Clone the Repository

git clone https://github.com/Reality361/opencv-object-detection-ui.git
cd opencv-object-detection-ui

πŸ”Ή 2. Install Dependencies

Ensure you have installed dependencies about OpenCV.

πŸ“Œ Dependencies include:

  • opencv-python
  • numpy

πŸ”Ή 3. Download YOLO Weights

The project requires YOLOv4-tiny pre-trained weights.
πŸ“₯ Download them from: YOLO Weights
Place them inside the dnn_model/ directory:

dnn_model/
 β”œβ”€β”€ yolov4-tiny.cfg
 β”œβ”€β”€ yolov4-tiny.weights
 β”œβ”€β”€ classes.txt

▢️ Running the Object Detector

python main4.py

πŸ“Œ Controls:

  • Click on buttons to enable/disable object detection for specific categories.
  • Scroll with the mouse wheel to navigate the object selection panel.
  • Press ESC to exit.

πŸ“œ How It Works

  1. Loads the YOLOv4-tiny model via OpenCV’s cv2.dnn_DetectionModel().
  2. Reads class labels from classes.txt.
  3. Captures frames from the webcam and processes them for detection.
  4. Detects objects based on confidence threshold.
  5. Draws bounding boxes and labels detected objects.
  6. Users can dynamically select objects to detect via an interactive UI.

🎨 UI Features

  • Scrollable Button Panel β†’ All object categories fit neatly.
  • Compact Button Layout β†’ Easy readability & interaction.
  • Smooth Click & Scroll Support β†’ Optimized for usability.

Example Object Categories:

Object Button Color
Person 🟦 Blue
Car πŸŸ₯ Red
Dog 🟩 Green
Bottle πŸŸͺ Purple

πŸ—οΈ How to Add More Object Categories?

  1. Edit dnn_model/classes.txt

    • Add the new object name on a new line.
  2. Modify initialize_buttons() in main4.py

    • New buttons are automatically added using the categories list.

πŸš€ Performance Optimization

  • Convert the model to ONNX for OpenCV acceleration:
    python export.py --weights best.pt --include onnx
  • Run with GPU acceleration (if supported):
    net.setPreferableBackend(cv2.dnn.DNN_BACKEND_CUDA)
    net.setPreferableTarget(cv2.dnn.DNN_TARGET_CUDA)

πŸ“ TODOs & Future Improvements

βœ” Enhance UI further with dynamic styling
βœ” Add support for YOLOv5
βœ” Train a custom model for additional objects
βœ” Optimize for edge devices like Raspberry Pi


πŸ“œ License

πŸ”“ This project is open-source and available under the MIT License.


πŸ“¬ Contact & Support

πŸ‘¨β€πŸ’» Maintainer: Reality361 πŸ’‘ Have questions? Open an issue.
πŸš€ Enjoyed the project? Give it a ⭐ on GitHub!

About

πŸš€ Object Detection with OpenCV & YOLO | Interactive UI 🎯

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages