A Python application (using tkinter) that detects and highlights a man wearing a cap from a live video feed using OpenCV and MobileNet SSD model (for person detection) . It is done using basic heuristics which checks for changes in colour, edges, or patterns in the head region.
- Cap images: Kaggle dataset ([(https://www.kaggle.com/datasets/shivanandverma/cap-dataset)])
- Pre-trained MobileNet SSD model: OpenCV
- Load pre-trained MobileNet SSD model for person detection.
- Load cap images from Kaggle dataset.
- Resize cap images to 100x100 pixels.
- Define a video stream function to capture frames from webcam.
- For each frame:
- Detect persons using MobileNet SSD model.
- Extract head region from detected persons.
- Resize head region to match cap image size.
- Use template matching (TM_CCOEFF_NORMED) to detect cap.
- Draw bounding box and label "Cap Detected" if cap is detected.
- Display video stream using Tkinter.
- OpenCV 4.x
- TensorFlow 2.x
- Tkinter
- Python 3.x
- Improve cap detection accuracy.
- Expand dataset for diverse cap styles.
- Integrate with other computer vision applications.