https://github.com/sowham-3098/basic-face-mask-ar-using-python-opencv
Face Mask AR is a Python program that detects faces in a live video stream and augments them with a mask image. This provides a fun and interactive way to try on different masks virtually.
https://github.com/sowham-3098/basic-face-mask-ar-using-python-opencv
augmented-reality face-detection opencv python3
Last synced: about 2 months ago
JSON representation
Face Mask AR is a Python program that detects faces in a live video stream and augments them with a mask image. This provides a fun and interactive way to try on different masks virtually.
- Host: GitHub
- URL: https://github.com/sowham-3098/basic-face-mask-ar-using-python-opencv
- Owner: Sowham-3098
- License: mit
- Created: 2023-06-17T18:04:03.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-06-18T17:09:39.000Z (about 3 years ago)
- Last Synced: 2025-01-15T23:17:30.457Z (over 1 year ago)
- Topics: augmented-reality, face-detection, opencv, python3
- Language: Python
- Homepage:
- Size: 3.64 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Face Mask AR
Face Mask AR is a Python program that detects faces in a live video stream and augments them with a mask image. This provides a fun and interactive way to try on different masks virtually.
## Requirements
- Python 3
- OpenCV library (`pip install opencv-python`)
- Haar cascade XML file for face detection (e.g., `haarcascade_frontalface_default.xml`) taken from `https://github.com/kipr/opencv/blob/master/data/haarcascades/haarcascade_frontalface_default.xml`
- Mask image with transparency (RGBA format)
## Usage
1. Clone the repository or download the Python script and the required image files.
2. Install the necessary libraries by running the following command in the terminal:
```pip install opencv-python```
3. Place the Haar cascade XML file (`haarcascade_frontalface_default.xml`) and the mask image (e.g., `mask.png`) in the same directory as the Python script.
4. Run the Python script in a terminal or IDE:
```python face_mask_ar.py```
5. The program will open a window showing the live video stream from your default webcam. It will detect faces in the video and augment them with the selected mask image.
6. To choose a different mask, press the "Q" key to exit the program and update the `mask.png` file with your desired mask image.
## Screenshots

*Example screenshot of the program displaying the live video stream with a detected face and a mask augmented on it.*
## Notes
- Ensure that your webcam is properly connected and accessible by the program.
- Experiment with different mask images to achieve the desired augmented reality effect.
- Adjust the face detection parameters in the script (e.g., scale factor, minimum neighbors) for better face detection results if needed.