Repository files navigation
Put on sunglasses for the camera.
You can inspect the face with sunglasses.
This project requires Python and OpenCV.
Requirements (Used in this repository):
command: python -m pip install opencv-python
detect_and_draw Function:
img: Current frame image read from the webcam
cascade: Haar Cascade classifier for face detection
nested_cascade: Haar Cascade classifier for eye detection
scale: Scale for resizing the image
try_flip: Flag for attempting eye direction
glasses: Sunglasses image
1. Convert the image read from the webcam to grayscale and resize it.
2. Use Haar Cascade to detect faces.
3. Find eyes around the detected face and calculate the center points of the eyes.
4. Overlay sunglasses on the face using the center points of both eyes.
5. Return the overlaid image.
background: Background image
foreground: Image to overlay
location: Location to overlay the image
1. Overlay sunglasses on the background image.
2. The transparent part of the sunglasses does not affect the background image.
3. Return the overlaid image.
Load Haar Cascade classifiers from the files
2. Load Sunglasses Image:
Load the sunglasses image from the 'sunglasses.png' file.
Open the webcam using OpenCV and begin reading frames.
Converts the frame to grayscale and resizes it.
Utilizes the Haar Cascade classifier to detect faces in the frame.
Locates eyes around the detected face and calculates their center points.
Overlays sunglasses on the face using the center points of the eyes.
If the 'q' key is pressed, the program exits.
You can’t perform that action at this time.