Skip to content

MichaelXu27/ColorDetection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Color Detection

Small OpenCV notebook for detecting a target color from a webcam stream.

Setup

  • Python 3.9+
  • numpy, opencv-python, Pillow

Install:

pip install numpy opencv-python Pillow

Usage

  1. Open ColorDetection.ipynb.
  2. Run the first cell to define get_limits().
  3. Run the webcam cell.
  4. Press q or close the window to exit.
  5. Change the color if wanted, the format is BGR

Notes

  • On macOS, cv2.CAP_AVFOUNDATION is used for stability.
  • On Windows or Linux, you can switch to cv2.VideoCapture(0) or a platform-specific backend (e.g., CAP_DSHOW or CAP_V4L2).

Recent changes

  • get_limits() now handles hue wrap-around (needed for red) and supports tuning hue_tol, sat_min, and val_min.
  • The webcam loop combines multiple HSV ranges (for red) and applies a light morphology + contour area filter to reduce false positives.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors