This project demonstrates real-time color detection using OpenCV and PIL (Python Imaging Library). The script captures video from the webcam, detects a specified color (yellow by default), and draws a bounding box around the detected color area in real-time.
Python 3.6+
OpenCV
PIL (Pillow)
NumPy
Clone the Repository:
git clone https://github.com/yourusername/ColorDetection.git
cd ColorDetectionCreate and activate a virtual environment (optional but recommended):
python3 -m venv color-detection-venv
source color-detection-venv/bin/activateInstall the required dependencies:
pip install opencv-python pillow numpy
Run the Script:
python main.pyThe script will access the webcam, detect the specified color (yellow by default), and display a live video feed with a bounding box drawn around the detected color area.
Change the Color to Detect:
The color to detect is specified in BGR format in the yellow variable:
python
yellow = [0, 255, 255] # yellow in BGRTo detect a different color, modify this variable with the desired BGR values. Quit the Video Feed: Press the q key to exit the video feed and close the webcam.