Real-time computer vision application that detects whether someone is wearing a quarter zip using YOLOv8 pose estimation and OpenCV edge detection.
- Real-time Detection: Analyzes webcam feed in real-time
- YOLOv8 Pose Estimation: Uses state-of-the-art pose detection to locate the neck area
- V-Shape Recognition: Detects the characteristic V-shaped collar of quarter zips
- Temporal Stability: Smoothed detection to prevent false positives
- Visual Feedback: Shows detection area and V-shape lines when quarter zip is detected
The detector identifies the neck area and looks for two diagonal lines forming a V-shape - the signature feature of a quarter zip collar.
- Pose Detection: YOLOv8 identifies key body points (nose, shoulders)
- ROI Extraction: Calculates neck region based on facial and shoulder landmarks
- Edge Detection: Uses Canny edge detection to find lines in the neck area
- V-Shape Matching: Identifies two diagonal lines (25-85° angles) forming a V
- Temporal Filtering: Applies exponential moving average for stable output
- Python 3.8+
- Webcam
-
Clone the repository
git clone https://github.com/kapilcdave/camera_detect.git cd camera_detect -
Create virtual environment
python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
Run the detector directly with OpenCV window:
python quarter_zip_detector.pyOr using the virtual environment directly:
./venv/bin/python quarter_zip_detector.pyControls: Press q to quit.
Run the web interface:
streamlit run streamlit_app.pyYou can adjust detection parameters in QuarterZipDetector.__init__:
self.alpha: Smoothing factor (lower = smoother/slower)self.lock_threshold: Frames to keep showing detection after lossself.conf_threshold: Detection confidence threshold- Edge detection parameters in
detect_v_shape()function
- YOLOv8: Pose estimation for body keypoint detection
- OpenCV: Image processing and edge detection
- NumPy: Numerical operations
- Streamlit: Web interface for easy deployment
- Locate neck region using nose and shoulder keypoints
- Apply Gaussian blur and Canny edge detection
- Use Hough Line Transform to detect line segments
- Filter lines by angle mechanism
- Verify V-shape formation by intersection logic
- Apply temporal smoothing for stable results
- opencv-python-headless
- ultralytics
- numpy
- streamlit
- Requires good lighting conditions
- Quarter zip zipper must be visible
- Single person detection (analyzes detected people independently)
- May trigger on other V-neck clothing
- Distinguish between quarter zips and other V-neck garments
- Add clothing color detection
- Support for video file input
- Performance optimization for lower-end hardware
MIT License - feel free to use and modify!
Contributions welcome! Please feel free to submit a Pull Request.
- YOLOv8 by Ultralytics
- OpenCV community