This project demonstrates real-time color detection using a webcam and OpenCV.
It detects a specific color (Green by default) in the live video feed and draws a bounding box around the detected object.
This project is beginner-friendly and great for learning:
- OpenCV basics
- Color spaces (BGR → HSV)
- Image masking
- Bounding box detection
- 📷 Real-time webcam video capture
- 🎨 HSV color space for accurate color detection
- 🟩 Bounding box around detected color
- 🔁 Handles HSV color wrap-around (important for Red)
- 🧠 Simple and clean logic for beginners
HSV (Hue, Saturation, Value) is better for color detection because:
- Hue represents the actual color
- Less affected by lighting changes
- Easier to define color ranges
color-detection/ main.py # Main script (video capture & detection) util.py # Helper function to get HSV limits requirements.txt # Python dependencies README.md # Documentation
git clone https://github.com/thanycodes/realtime-colour-tracker.git
cd realtime-colour-trackerpython -m venv venv
source venv/bin/activate # macOS / Linux
venv\Scripts\activate # Windowspip install -r requirements.txtRun the main script:
python main.py