This project is a real-time Hat Try-On application using OpenCV, Python, and Haar Cascade for face detection. The application allows users to overlay different hat images on their faces captured through a webcam.
- Real-time face detection.
- Select different hats from a sidebar by clicking.
- Navigate through hats using keyboard shortcuts (
n
for next hat,p
for previous hat). - Hats are resized and positioned according to the detected face dimensions.
- Python 3.x
- OpenCV
- NumPy
- Pillow
You can install the required libraries using the following command:
pip install opencv-python numpy pillow
- Clone this repository.
- Ensure the hat images are in a folder named
hats
in the same directory as the script. - Run the Python script:
python main.py
- The app will automatically open your webcam.
- The sidebar on the right shows different hats available for overlay.
- Click on a hat to select it or use the keyboard shortcuts (
n
for next,p
for previous). - Press
q
to quit the application.