A real-time colour-based object tracking system using Python and OpenCV. The system identifies and tracks a specific coloured object in a live webcam feed using HSV colour masking — no machine learning required.
[Live Webcam Feed]
→ Frame converted to HSV colour space
→ Colour mask applied (e.g., red/blue/green object)
→ Matching object highlighted with bounding box
→ Tracked in real-time as object moves
- HSV Conversion — Each frame is converted from BGR to HSV colour space for better colour isolation
- Colour Masking — A predefined HSV range is applied to isolate the target colour
- Noise Reduction — Morphological operations (erosion + dilation) clean up the mask
- Contour Detection — Finds the largest matching contour (the tracked object)
- Bounding Box — Draws a rectangle around the detected coloured object
| Tool | Purpose |
|---|---|
| Python 3.x | Core programming language |
| OpenCV | HSV masking, contour detection, real-time video |
# Clone the repository
git clone https://github.com/arunkumararavindhakshan05-sudo/Moving_object_detection_using_colour.git
cd Moving_object_detection_using_colour
# Install dependencies
pip install opencv-python numpypython colour_tracker.py💡 To track a different colour, update the HSV range values in the script for your target colour.
Controls:
- Press
Q— Quit the camera feed
Moving_object_detection_using_colour/
│
├── colour_tracker.py # Main tracking script
└── README.md
- Add UI slider to adjust HSV range dynamically
- Support multiple colour tracking simultaneously
- Log object path/trajectory on screen
- Export tracking coordinates to CSV