- Dong Nguyen
- Parth Gupta
- Ka Hin Choi
This program uses OpenCV to detect human faces, eyes, and smiles on a video stream. It determines human emotions (happy or sad) based on collected facial features and applies filters accordingly. When no face is detected or the local computer camera is unavailable, it shows appropriate messages. It adds a teardrop filter below the human eye when detecting a sad emotion and a rainbow on the mouth when detecting a happy emotion.
-
Clone and open the repository:
git clone https://github.com/parthgu/EmotifilterFX
-
Create and activate a virtual environment:
-
Create virtual environment:
python -m venv myenv
-
Activate the virtual environment:
- Mac/Linux:
source myenv/bin/activate
- Windows:
myenv\Scripts\activate
- Mac/Linux:
-
-
Install the required dependencies:
pip install -r requirements.txt
-
Ensure you have the necessary cascade files:
haarcascade_frontalface_default.xml
haarcascade_smile.xml
haarcascade_eye.xml
If you don't have them, you can download them from the OpenCV GitHub repository and place them in a directory named
cascades
. -
Ensure you have the filter images:
teardrop.png
rainbowsmile.png
angry-eyebrows,png
fire.png
exclamation.png
-
Activate the virtual environment if not already activated:
- Mac/Linux:
source myenv/bin/activate
- Windows:
myenv\Scripts\activate
- Mac/Linux:
-
Run the program:
python main.py
-
The program will open a window displaying the video stream from your camera. If your computer has multiple cameras, you might need to edit
main.py
and change the value ofvideo = cv2.VideoCapture(1)
tovideo = cv2.VideoCapture(0)
or another index to select the correct camera. -
The program will detect faces, eyes, and smiles, and apply the corresponding filters based on detected emotions:
- A teardrop filter will be applied below the eye when no smile is detected (indicating sadness).
- A rainbow filter will be applied on the mouth when a smile is detected (indicating happiness).
-
Press the
Esc
key (ASCII 27) to close the video window and stop the program.
- If the program cannot open the camera, you will see an error message: "Error: Could not open camera."
- If the program cannot load the face, smile, or eye detectors, you will see error messages indicating which detector could not be loaded.
- Ensure that the paths to the cascade files and filter images are correct and the files exist in the specified directories.
This project is licensed under the MIT License.